diff --git a/.fernignore b/.fernignore index 98b6df5f..8aa8afdc 100644 --- a/.fernignore +++ b/.fernignore @@ -34,6 +34,14 @@ # standardwebhooks declaration survived, which is where Ruby's ci.yml guard would sit if # this repo's ci.yml were hand-written; it is not, and forking it for a guard is a worse # trade than putting the guard in a test. +# +# 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/publish-main.yml src/whop_sdk/lib tests/custom diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 00000000..d8521224 --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,35 @@ +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: 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 }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --auto --squash