From eda9f6a8bf768089bf60cdac577c3c76208292d7 Mon Sep 17 00:00:00 2001 From: Sebastien Taggart Date: Sat, 11 Apr 2026 20:43:18 -0400 Subject: [PATCH] Add GitHub Action to auto-sync dev with main after PR merges --- .github/workflows/sync-dev.yml | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/sync-dev.yml diff --git a/.github/workflows/sync-dev.yml b/.github/workflows/sync-dev.yml new file mode 100644 index 0000000..5b73771 --- /dev/null +++ b/.github/workflows/sync-dev.yml @@ -0,0 +1,38 @@ +name: Sync dev with main + +on: + push: + branches: [main] + +permissions: + contents: write + issues: write + +jobs: + sync-dev: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Fast-forward dev to main + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + git checkout dev + if git merge --ff-only origin/main; then + git push origin dev + echo "✅ dev fast-forwarded to match main" + else + echo "❌ Fast-forward failed — dev has diverged from main" + gh issue create \ + --title "Dev branch has diverged from main and needs manual sync" \ + --label "bug" \ + --body "The automatic fast-forward of \`dev\` to \`main\` failed. This means \`dev\` has commits that are not on \`main\`, preventing an automatic sync.\n\nPlease manually reconcile the branches:\n\`\`\`bash\ngit checkout dev\ngit merge main\n\`\`\`\n\nTriggered by push to main: ${{ github.sha }}" + exit 1 + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}