From 3a1d223b758e012c9329dd7a2d3fedddef096f2a Mon Sep 17 00:00:00 2001 From: hsinatfootprintai <149764663+hsinatfootprintai@users.noreply.github.com> Date: Tue, 27 Oct 2026 11:35:50 +0800 Subject: [PATCH] ci: turn on auto-merge for bot-opened PRs that a person labels automerge A labeled pull request authored by the Containarium bot gets GitHub's squash auto-merge enabled; GitHub merges it once the required status checks pass. A pull request that touches .github/ is refused. The workflow runs from the base branch (pull_request_target) and checks out no PR code. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/automerge.yml | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..9381fca --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,34 @@ +# Turns on GitHub auto-merge (squash) for a pull request that the Containarium +# bot opened, once a person labels it `automerge`. GitHub then merges it as +# soon as the branch's required status checks pass; this workflow never merges +# anything itself. +# +# Runs from the base branch (pull_request_target) and checks out no pull request +# code, so a pull request cannot change how it is merged. A pull request that +# touches .github/ is refused: a workflow change needs a person to merge it. +name: automerge +on: + pull_request_target: + types: [labeled] +permissions: + contents: write + pull-requests: write +jobs: + enable: + if: >- + github.event.label.name == 'automerge' && + github.event.pull_request.user.login == 'containarium-ci[bot]' + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} + steps: + - name: Refuse a pull request that touches .github/ + run: | + if gh api "repos/$REPO/pulls/$PR/files" --paginate --jq '.[].filename' | grep -q '^\.github/'; then + echo "::error::PR #$PR changes .github/; a person must merge it. Auto-merge not enabled." + exit 1 + fi + - name: Enable auto-merge (squash) + run: gh pr merge "$PR" --repo "$REPO" --auto --squash