Skip to content

Commit d6e89dc

Browse files
authored
Merge pull request #10 from lorem-dev/develop
ci: add back-merge main -> develop workflow
2 parents 93723ff + 3b02891 commit d6e89dc

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

‎.github/workflows/backmerge.yml‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Back-merge main -> develop
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
concurrency:
12+
group: backmerge
13+
cancel-in-progress: false
14+
15+
jobs:
16+
open-backmerge-pr:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Skip if develop already contains main
24+
id: check
25+
run: |
26+
if git merge-base --is-ancestor origin/main origin/develop; then
27+
echo "needs_pr=false" >> "$GITHUB_OUTPUT"
28+
echo "develop already contains main; nothing to do."
29+
else
30+
echo "needs_pr=true" >> "$GITHUB_OUTPUT"
31+
fi
32+
33+
- name: Open or update back-merge PR
34+
if: steps.check.outputs.needs_pr == 'true'
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
MAIN_SHA="$(git rev-parse --short origin/main)"
39+
MAIN_SUBJECT="$(git log -1 --format='%s' origin/main)"
40+
41+
EXISTING="$(gh pr list --head main --base develop --state open --json number --jq '.[0].number')"
42+
if [ -n "$EXISTING" ]; then
43+
echo "PR #$EXISTING already open for main -> develop; it will auto-update with the new push."
44+
exit 0
45+
fi
46+
47+
gh pr create \
48+
--base develop \
49+
--head main \
50+
--title "chore: back-merge main into develop" \
51+
--body "Automated back-merge of \`main\` into \`develop\`.
52+
53+
Latest commit on main: \`$MAIN_SHA\` - $MAIN_SUBJECT
54+
55+
Triggered by push to \`main\` in workflow \`${{ github.workflow }}\` run \`${{ github.run_id }}\`.
56+
57+
Merge this PR (or enable auto-merge on it) to keep \`develop\` in sync with the latest release commit on \`main\`. Resolve any conflicts manually before merging.
58+
59+
> **Note on GPG**: the merge commit GitHub creates when you click \"Merge pull request\" is signed by \`web-flow\`. The locksmith \`make verify\` GPG gate already ignores web-flow merge commits, so this back-merge will not break verification on \`develop\`."

0 commit comments

Comments
 (0)