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