Debian Codegraph @

.github/workflows/retry_build.yml

raw
1 name: Retry Build
2 on:
3 workflow_dispatch:
4 inputs:
5 run_id:
6 required: true
7 jobs:
8 rerun-on-failure:
9 permissions: write-all
10 runs-on: ubuntu-latest
11 steps:
12 - name: rerun ${{ inputs.run_id }}
13 env:
14 GH_REPO: ${{ github.repository }}
15 GH_TOKEN: ${{ github.token }}
16 GH_DEBUG: api
17 run: |
18 # status can be one of "queued", "in_progress", "completed", "waiting", "requested", "pending"
19 # https://docs.github.com/en/rest/checks/runs
20 # while not completed, sleep for 10 minutes
21 while gh run view ${{ inputs.run_id }} --json status | grep -v completed
22 do
23 echo Workflow in progress - sleeping for 10 minutes then checking again
24 sleep 10m
25 done
26
27 # Only retry if there are failed jobs
28 if gh run view ${{ inputs.run_id }} --exit-status; then
29 echo Workflow succeeded - no retry necessary.
30 else
31 echo Workflow failed - initiating retry.
32 gh run rerun ${{ inputs.run_id }} --failed
33 fi