-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: the github
action outputs the wrong ref when it contains a /
#11
Comments
/
, like feat/my-feat
github
action outputs the wrong ref when it contains a /
@galargh I can fix this by replacing the match with something like: action_ref=$(echo "$ACTION_PATH" | sed -n 's#_actions/[a-zA-Z0-9]*/[a-zA-Z0-9]*/\([a-zA-Z0-9/]*\)/.github/.*#\1#p') But since we're doing pretty much the same match three time, would it be cool if I moved this to a js script and used capture groups, regexp, etc? |
This one's a little tricky because action directories are not well-defined. The action path follows the pattern of However, there's one thing we could do. After action directory is downloaded, It could come together to something like this. # The relative path to the action directory, without /home/runner/work/_actions/ prefix
action_rel_path=${ACTION_PATH#*/_actions/}
# The root directory where actions are stored, e.g. /home/runner/work/_actions
action_root_path=${ACTION_PATH%/$action_rel_path}
# The first two parts of the relative path represent the action repository
action_repository=$(echo $action_rel_path | cut -d/ -f1-2)
action_sha=''
action_completed_path=$ACTION_PATH
# Looking $action_root_path/$action_repository/$action_ref.completed file recursively
while [[ ! -f $action_completed_path.completed && $action_completed_path != $action_root_path/$action_repository ]]; do
action_completed_path=$(dirname $action_completed_path);
done
if [[ $action_completed_path == $action_root_path/$action_repository ]]; then
# The completed file doesn't exist, we fall back to assuming the third part of the relative path is the action reference (assumes no slashes in the reference)
action_ref=$(echo $action_rel_path | cut -d/ -f3)
else
# The completed file exists, everything from the third part until the end of the relative path to the completed file is the exact action reference
action_ref=$(echo ${action_completed_path#*/_actions/} | cut -d/ -f3-)
fi
echo "action_repository=$action_repository" | tee -a $GITHUB_OUTPUT
echo "action_ref=$action_ref" | tee -a $GITHUB_OUTPUT
echo "action_sha=$action_sha" | tee -a $GITHUB_OUTPUT |
https://github.com/singulargarden/kubo/actions/runs/5893416836/job/15984909672
I called an action using a branch named
feat/with-job-url
:The action's context:
Which breaks the ref computation:
The text was updated successfully, but these errors were encountered: