Skip to content

fix: account for extra long job names #488

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

Merged
merged 25 commits into from
Aug 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/examples/pr_merge_matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
uses: op5dev/tf-via-pr@v13
with:
working-directory: path/to/${{ matrix.deployment }}
tool: tofu
command: ${{ github.event_name == 'merge_group' && 'apply' || 'plan' }}
arg-refresh: ${{ github.event_name == 'merge_group' && 'false' || 'true' }} # Skip refresh on apply.
arg-lock: ${{ github.event_name == 'merge_group' }}
arg-var-file: env/${{ matrix.deployment }}.tfvars
arg-workspace: ${{ matrix.deployment }}
plan-encrypt: ${{ secrets.PASSPHRASE }}
plan-parity: true # Prevents stale apply within merge queue.
tool: tofu
7 changes: 2 additions & 5 deletions .github/workflows/test_aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ jobs:
uses: ./
with:
working-directory: tests/aws/targets/${{ matrix.target }}
tool: tofu
command: ${{ github.event_name == 'merge_group' && 'apply' || 'plan' }}
arg-lock-timeout: 3m

plan-encrypt: secrets.TF_ENCRYPTION
plan-parity: true
retention-days: 1

expand-diff: true
tag-actor: never
tool: tofu

- name: Troubleshoot TF
if: ${{ failure() && github.event_name == 'merge_group' }}
Expand All @@ -132,12 +130,11 @@ jobs:
uses: ./
with:
working-directory: tests/aws/targets/${{ matrix.target }}
tool: tofu
command: apply
arg-auto-approve: true
arg-lock-timeout: 3m

comment-pr: false
tool: tofu

Notify:
runs-on: [ubuntu-24.04]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
uses: ./
with:
working-directory: tests/${{ matrix.test }}
tool: ${{ matrix.tool }}
command: ${{ github.event.pull_request.merged && 'apply' || 'plan' }}
arg-lock: ${{ github.event.pull_request.merged }}
arg-refresh: ${{ github.event.pull_request.merged && 'false' || 'true' }}
Expand All @@ -78,7 +79,6 @@ jobs:
expand-diff: true
hide-args: detailed-exitcode,lock,out,refresh
tag-actor: never
tool: ${{ matrix.tool }}

- name: Echo TF
continue-on-error: true
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ runs:
else
# For matrix jobs, join the matrix values with comma separator into a single string and get the ID of the job which contains it.
matrix=$(echo "$GH_MATRIX" | jq --raw-output 'to_entries | map(if .value | type == "object" then (.value | to_entries[0].value) else .value end) | join(", ")')
job_id=$(echo "$workflow_run" | jq --raw-output --arg matrix "$matrix" '.jobs[] | select(.name | contains($matrix)) | .id' | tail -n 1)
job_id=$(echo "$workflow_run" | jq --raw-output --arg matrix "$matrix" '.jobs[] | select((.name | split("(")[1]) | rtrimstr(")") | rtrimstr("...") | inside($matrix)) | .id' | tail -n 1)
# For dynamic matrix jobs, retry with exponential backoff until the job ID is found or a timeout occurs.
retry_interval=1
while [[ -z "$job_id" ]]; do
Expand All @@ -325,7 +325,7 @@ runs:
sleep "$retry_interval"
retry_interval=$((retry_interval * 2))
workflow_run=$(gh api /repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs --header "$GH_API" --method GET --paginate)
job_id=$(echo "$workflow_run" | jq --raw-output --arg matrix "$matrix" '.jobs[] | select(.name | contains($matrix)) | .id' | tail -n 1)
job_id=$(echo "$workflow_run" | jq --raw-output --arg matrix "$matrix" '.jobs[] | select((.name | split("(")[1]) | rtrimstr(")") | rtrimstr("...") | inside($matrix)) | .id' | tail -n 1)
done
fi
echo "job=$job_id" >> "$GITHUB_OUTPUT"
Expand Down
Loading