Retry Workflow #134
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Retry Workflow | |
on: | |
workflow_run: | |
workflows: ["CI", "CI - Every OS"] | |
types: | |
- completed | |
permissions: | |
contents: write | |
actions: write | |
jobs: | |
rerun: | |
runs-on: ubuntu-24.04 | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
steps: | |
- name: Check attempt count | |
id: check_attempts | |
env: | |
GH_TOKEN: ${{ github.token }} | |
GH_REPO: ${{ github.repository }} | |
run: | | |
attempt=$(gh run view ${{ github.event.workflow_run.id }} --json attempt -q ".attempt") | |
echo "Current attempt: $attempt" | |
if [ $attempt -lt 3 ]; then | |
echo "attempt_allowed=true" >> $GITHUB_OUTPUT | |
else | |
echo "attempt_allowed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Sleep for 60 seconds | |
if: steps.check_attempts.outputs.attempt_allowed == 'true' | |
run: sleep 60s | |
shell: bash | |
- name: rerun ${{ github.event.workflow_run.id }} | |
if: steps.check_attempts.outputs.attempt_allowed == 'true' | |
env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh run watch ${{ github.event.workflow_run.id }} > /dev/null 2>&1 | |
gh run rerun ${{ github.event.workflow_run.id }} --failed |