From acdc5c36a1657f643ecd8419406954eb6f031042 Mon Sep 17 00:00:00 2001 From: icepaq <288199041+antonwhop@users.noreply.github.com> Date: Mon, 24 Aug 2026 13:56:50 -0700 Subject: [PATCH] ci: arm auto-merge on Fern regeneration PRs Adds a pull_request_target workflow that enables squash auto-merge for pull requests opened by fern-api[bot] from an in-repo fern-bot/* branch, and lists it in .fernignore so a regeneration cannot prune it. --- .fernignore | 8 ++++++++ .github/workflows/auto-merge.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/auto-merge.yml diff --git a/.fernignore b/.fernignore index 084a8ebb..f509f865 100644 --- a/.fernignore +++ b/.fernignore @@ -1 +1,9 @@ # Specify files that shouldn't be modified by Fern +# +# auto-merge.yml is hand-written and arms Fern's own regeneration PRs. On pull_request_target +# it enables auto-merge (squash) for a pull request opened by fern-api[bot] from an in-repo +# fern-bot/* branch against the default branch, so the pull request merges itself once main's +# required status checks pass. The trigger is pull_request_target rather than pull_request so +# the workflow that arms a pull request is always the copy already on the base branch, never +# the copy that pull request carries. +.github/workflows/auto-merge.yml diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 00000000..deca1d63 --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,29 @@ +name: Auto-merge + +on: + pull_request_target: + types: [opened, reopened, synchronize] + +permissions: + contents: write + pull-requests: write + +concurrency: + group: auto-merge-${{ github.event.pull_request.number }} + cancel-in-progress: false + +jobs: + arm: + if: >- + github.event.pull_request.user.id == 115122769 && + github.event.pull_request.user.login == 'fern-api[bot]' && + github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.base.ref == github.event.repository.default_branch && + startsWith(github.event.pull_request.head.ref, 'fern-bot/') + runs-on: ubuntu-latest + steps: + - name: Enable auto-merge + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --auto --squash