Skip to content

Commit 774cfff

Browse files
authored
fix: variable substitution in jq (#425)
Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com>
1 parent 93a0b46 commit 774cfff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ runs:
7979
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
8080
# List PRs associated with the commit, then get the PR number from the head ref or the latest PR.
8181
associated_prs=$(gh api /repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha || github.sha }}/pulls --header "$GH_API" --method GET --field per_page=100)
82-
pr_number=$(echo "$associated_prs" | jq --raw-output '(.[] | select(.head.ref == ${{ github.ref_name }}) | .number) // .[0].number // 0')
82+
pr_number=$(echo "$associated_prs" | jq --raw-output '(.[] | select(.head.ref == env.GITHUB_REF_NAME) | .number) // .[0].number // 0')
8383
elif [[ "$GITHUB_EVENT_NAME" == "merge_group" ]]; then
8484
# Get the PR number by parsing the ref name.
8585
pr_number=$(echo "${{ github.ref_name }}" | sed -n 's/.*pr-\([0-9]*\)-.*/\1/p')
@@ -101,7 +101,7 @@ runs:
101101
if [[ "$GH_MATRIX" == "null" ]]; then
102102
# For regular jobs, get the ID of the job with the same name as job_id (lowercase and '-' or '_' replaced with ' ').
103103
# Otherwise, get the ID of the first job in the list as a fallback.
104-
job_id=$(echo "$workflow_run" | jq --raw-output '(.jobs[] | select((.name | ascii_downcase | gsub("-|_"; " ")) == (${{ github.job }} | ascii_downcase | gsub("-|_"; " "))) | .id) // .jobs[0].id' | tail -n 1)
104+
job_id=$(echo "$workflow_run" | jq --raw-output '(.jobs[] | select((.name | ascii_downcase | gsub("-|_"; " ")) == (env.GITHUB_JOB | ascii_downcase | gsub("-|_"; " "))) | .id) // .jobs[0].id' | tail -n 1)
105105
else
106106
# For matrix jobs, join the matrix values with comma separator into a single string and get the ID of the job which contains it.
107107
matrix=$(echo "$GH_MATRIX" | jq --raw-output 'to_entries | map(.value) | join(", ")')

0 commit comments

Comments
 (0)