--- name: Keep master green on: schedule: # run hourly - cron: "0 * * * *" workflow_dispatch: inputs: ref: required: false permissions: contents: read jobs: rerun-failed-jobs: if: github.repository_owner == 'emqx' runs-on: ubuntu-22.04 permissions: checks: read actions: write steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: ref: ${{ github.event.inputs.ref || 'master' }} - name: run script shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh api --method GET -f head_sha=$(git rev-parse HEAD) -f status=completed -f exclude_pull_requests=true /repos/emqx/emqx/actions/runs > runs.json for id in $(jq -r '.workflow_runs[] | select((."conclusion" != "success") and .run_attempt < 3) | .id' runs.json); do echo "rerun https://github.com/emqx/emqx/actions/runs/$id" gh api --method POST /repos/emqx/emqx/actions/runs/$id/rerun-failed-jobs done