From f0b0d53eef879a27b2ffe7e6d8d935f5e68484aa Mon Sep 17 00:00:00 2001 From: Daniel Morris Date: Tue, 19 May 2026 17:57:10 +0100 Subject: [PATCH] chore: auto-sync next branch from main on push --- .github/workflows/sync-next.yml | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/sync-next.yml diff --git a/.github/workflows/sync-next.yml b/.github/workflows/sync-next.yml new file mode 100644 index 00000000..55329bed --- /dev/null +++ b/.github/workflows/sync-next.yml @@ -0,0 +1,41 @@ +name: sync next from main + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: next + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - name: Try fast-forward + id: ff + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if git merge --ff-only origin/main; then + echo "result=ff" >> "$GITHUB_OUTPUT" + git push origin next + else + echo "result=diverged" >> "$GITHUB_OUTPUT" + fi + - name: Open sync PR if diverged + if: steps.ff.outputs.result == 'diverged' + uses: peter-evans/create-pull-request@v6 + with: + branch: chore/sync-next-from-main + base: next + title: "chore: sync next from main" + body: | + Automated PR — `next` could not fast-forward from `main`. + Resolve any conflicts, then merge to bring `next` current. + delete-branch: true