|
| 1 | +# Auto-merge — nobody is in the merge loop. |
| 2 | +# |
| 3 | +# Green, ready PRs merge themselves and deploy themselves. The owner does not |
| 4 | +# review PRs, and background-job agent sessions are barred from merging by hand, |
| 5 | +# so the policy lives in scripts/ci/auto-merge-sweep.sh (read it — it defines |
| 6 | +# exactly what "ready" means and how a PR is held back). |
| 7 | +# |
| 8 | +# Two triggers, deliberately: |
| 9 | +# workflow_run — merges within seconds of CI going green (the common path). |
| 10 | +# schedule — a safety net. Catches PRs whose checks finished while this |
| 11 | +# workflow was failing/disabled, and PRs whose last check was |
| 12 | +# an external status that reported after CI. Without it, a PR |
| 13 | +# that went green "off-cycle" waits forever. |
| 14 | +# |
| 15 | +# To stop all of this: delete this file, or add a `hold` label to a PR. |
| 16 | + |
| 17 | +name: Auto-merge |
| 18 | + |
| 19 | +on: |
| 20 | + workflow_run: |
| 21 | + workflows: ['CI'] |
| 22 | + types: [completed] |
| 23 | + schedule: |
| 24 | + - cron: '*/10 * * * *' |
| 25 | + workflow_dispatch: {} |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: write # merge the PR |
| 29 | + pull-requests: write # read PR state, delete the branch |
| 30 | + actions: write # dispatch the re-arm workflows |
| 31 | + |
| 32 | +# Never let two sweeps merge concurrently — they would race on the same PRs. |
| 33 | +concurrency: |
| 34 | + group: auto-merge |
| 35 | + cancel-in-progress: false |
| 36 | + |
| 37 | +jobs: |
| 38 | + sweep: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + timeout-minutes: 10 |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Merge every green, ready PR |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + GH_REPO: ${{ github.repository }} |
| 48 | + BASE_BRANCH: ${{ github.event.repository.default_branch }} |
| 49 | + CI_WORKFLOW: ci.yml |
| 50 | + # Everything that runs on push and therefore would NOT fire after a |
| 51 | + # merge made with the default GITHUB_TOKEN. Keep this in sync when a |
| 52 | + # push-triggered workflow is added. |
| 53 | + REARM_WORKFLOWS: ci.yml |
| 54 | + run: bash scripts/ci/auto-merge-sweep.sh |
0 commit comments