File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Tests auto-rerun
2+
3+ on :
4+ workflow_run :
5+ workflows : [ "Tests" ]
6+ types : [ completed ]
7+
8+ jobs :
9+ rerun-failed-matrix-jobs-once :
10+ if : >
11+ ${{
12+ github.event.workflow_run.conclusion == 'failure' &&
13+ github.event.workflow_run.run_attempt == 1
14+ }}
15+ runs-on : ubuntu-24.04
16+
17+ permissions :
18+ actions : write
19+ contents : read
20+
21+ steps :
22+ - name : Decide whether to rerun (only if matrix jobs failed)
23+ env :
24+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
25+ REPO : ${{ github.repository }}
26+ RUN_ID : ${{ github.event.workflow_run.id }}
27+ run : |
28+ echo "Inspecting jobs of workflow run $RUN_ID in $REPO"
29+
30+ jobs_json="$(gh api repos/$REPO/actions/runs/$RUN_ID/jobs)"
31+
32+ echo "Jobs and conclusions:"
33+ echo "$jobs_json" | jq '.jobs[] | {name: .name, conclusion: .conclusion}'
34+
35+ failed_matrix_jobs=$(echo "$jobs_json" | jq '
36+ [ .jobs[]
37+ | select(.conclusion == "failure"
38+ and (.name | startswith("Integration Tests (")))
39+ ]
40+ | length
41+ ')
42+
43+ echo "Failed Integration Tests matrix jobs: $failed_matrix_jobs"
44+
45+ if [ "$failed_matrix_jobs" -gt 0 ]; then
46+ echo "Detected failing Integration Tests jobs – re-running failed jobs for this run."
47+ gh run rerun "$RUN_ID" --failed
48+ else
49+ echo "Only non-matrix jobs (like Test Results) failed – not auto-rerunning."
50+ fi
You can’t perform that action at this time.
0 commit comments