Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/sync-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# After a staging → main merge, GitHub's merge commit leaves main one commit
# ahead of staging even when the trees match. Fast-forward staging to main
# so the branches stay tip-aligned (same pattern as unify/orchestra/etc.).
name: Sync staging with main

permissions:
contents: write

on:
push:
branches:
- main

jobs:
sync:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fast-forward staging to main (only if staging has no unreleased work)
run: |
main_sha=$(git rev-parse origin/main)
staging_sha=$(git rev-parse origin/staging)
echo "main is at: $main_sha"
echo "staging is at: $staging_sha"

if [ "$main_sha" = "$staging_sha" ]; then
echo "staging is already in sync with main"
exit 0
fi

# Check if staging is an ancestor of main, meaning main already
# contains everything on staging (e.g. staging was merged to main).
# If staging has commits that main doesn't, skip to avoid data loss.
if ! git merge-base --is-ancestor "$staging_sha" "$main_sha"; then
echo "::warning::Skipping sync — staging has commits not yet in main"
exit 0
fi

gh api repos/${{ github.repository }}/git/refs/heads/staging \
-X PATCH \
-f sha="$main_sha" \
-F force=true

echo "Fast-forwarded staging to $main_sha"
Loading