From 1f5066cbfb6ac0b36832dbd057ef8f2a99cd5c57 Mon Sep 17 00:00:00 2001 From: icepaq <288199041+antonwhop@users.noreply.github.com> Date: Mon, 24 Aug 2026 13:56:39 -0700 Subject: [PATCH 1/2] 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 08381c0e..313293a8 100644 --- a/.fernignore +++ b/.fernignore @@ -66,6 +66,14 @@ # patch returns a Float unchanged when it has a fractional part, and still normalises whole # floats to Integer so genuinely integral fields are unaffected. Delete this entry and the # file once fern-ruby-sdk maps `number` to Float. +# +# 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 .github/workflows/ci.yml .github/workflows/publish-main.yml CHANGELOG.md 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 From 3c0aa0fd3bb42ad951c03859c8dd9a33fa8f82f4 Mon Sep 17 00:00:00 2001 From: antonwhop Date: Mon, 24 Aug 2026 16:53:45 -0700 Subject: [PATCH 2/2] ci: approve the Fern PR so the armed auto-merge can satisfy the required review --- .github/workflows/auto-merge.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index deca1d63..d8521224 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -22,6 +22,12 @@ jobs: startsWith(github.event.pull_request.head.ref, 'fern-bot/') runs-on: ubuntu-latest steps: + - name: Approve + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: gh pr review "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --approve + - name: Enable auto-merge env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}