Skip to content

Commit a397335

Browse files
Add workflow to auto-propagate main changes to deployment branches
Merges main into modal and hetzner on every push. Opens a PR instead when there are merge conflicts. Closes #169 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9abbeb2 commit a397335

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/propagate.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: propagate
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
propagate:
13+
strategy:
14+
matrix:
15+
branch: [modal, hetzner]
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Generate token
19+
id: create_token
20+
uses: tibdex/github-app-token@v2
21+
with:
22+
app_id: ${{ secrets.APP_ID }}
23+
private_key: ${{ secrets.PRIVATE_KEY }}
24+
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
token: ${{ steps.create_token.outputs.token }}
30+
31+
- name: Attempt merge and push, or open PR on conflict
32+
env:
33+
GH_TOKEN: ${{ steps.create_token.outputs.token }}
34+
BRANCH: ${{ matrix.branch }}
35+
run: |
36+
git config user.name "github-actions[bot]"
37+
git config user.email "github-actions[bot]@users.noreply.github.com"
38+
39+
git checkout "$BRANCH"
40+
41+
if git merge origin/main --no-edit; then
42+
echo "Merge succeeded, pushing to $BRANCH"
43+
git push origin "$BRANCH"
44+
else
45+
echo "Merge conflict detected, opening PR"
46+
git merge --abort
47+
48+
# Create a temporary branch for the PR
49+
TEMP_BRANCH="auto-merge/main-to-${BRANCH}-$(date +%Y%m%d%H%M%S)"
50+
git checkout -b "$TEMP_BRANCH" origin/main
51+
52+
git push origin "$TEMP_BRANCH"
53+
54+
gh pr create \
55+
--base "$BRANCH" \
56+
--head "$TEMP_BRANCH" \
57+
--title "Propagate main to ${BRANCH}" \
58+
--body "$(cat <<'PREOF'
59+
## Summary
60+
- Auto-generated PR to propagate changes from `main` to the deployment branch
61+
- Opened because an automatic merge had conflicts that need manual resolution
62+
63+
🤖 Generated by the propagate workflow
64+
PREOF
65+
)"
66+
fi

0 commit comments

Comments
 (0)