Skip to content

Instantly share code, notes, and snippets.

@Borda
Last active September 20, 2023 09:08
Show Gist options
  • Select an option

  • Save Borda/89967be8e583b41ba6f3ed59ec05934f to your computer and use it in GitHub Desktop.

Select an option

Save Borda/89967be8e583b41ba6f3ed59ec05934f to your computer and use it in GitHub Desktop.
blog_retry-failed-checks
name: Sample build
on:
- push
- pull_request
- workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: pip --version
- name: Test failing...
if: github.run_attempt < 3
run: exit 1
- name: Test passed!
run: echo "GREEN"
name: Rerun PR if failed
on:
workflow_run:
workflows: ["Sample build"]
types: ["completed"]
permissions:
actions: write
jobs:
rerun-pr:
runs-on: ubuntu-latest
# Only rerun on the PR if it comes from a PR event
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: browse event context
run: echo '${{ toJSON(github.event.workflow_run) }}'
- name: Needed details
run: |
echo "ID: ${{ github.event.workflow_run.id }}"
echo "attempt: ${{ github.event.workflow_run.run_attempt }}"
echo "event: ${{ github.event.workflow_run.conclusion }}"
echo "event: ${{ github.event.workflow_run.event }}"
- name: Rerun Failed Workflows
if: github.event.workflow_run.conclusion == 'failure' && github.event.run_attempt <= 3
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
gh --version
gh run rerun ${RUN_ID} --repo="${{ github.repository }}" --failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment