File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Opens a PR from master → development after changes land on master (back-merge).
2+ #
3+ # Permissions: default GITHUB_TOKEN needs repo Settings → Actions → General →
4+ # "Workflow permissions" = read and write (to create pull requests). If your org
5+ # restricts this, create a fine-grained PAT with contents:read + pull-requests:write,
6+ # store it as repo secret GH_TOKEN, and set GH_TOKEN on the "Open back-merge PR" step to:
7+ # env:
8+ # GH_TOKEN: ${{ secrets.GH_TOKEN }}
9+
10+ name : Back-merge master to development
11+
12+ on :
13+ push :
14+ branches : [master]
15+ workflow_dispatch :
16+
17+ permissions :
18+ contents : read
19+ pull-requests : write
20+
21+ jobs :
22+ open-back-merge-pr :
23+ runs-on : ubuntu-latest
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
27+ with :
28+ fetch-depth : 0
29+
30+ - name : Open back-merge PR if needed
31+ env :
32+ GH_TOKEN : ${{ github.token }}
33+ run : |
34+ set -euo pipefail
35+ git fetch origin development master
36+
37+ MASTER_SHA=$(git rev-parse origin/master)
38+ DEV_SHA=$(git rev-parse origin/development)
39+
40+ if [ "$MASTER_SHA" = "$DEV_SHA" ]; then
41+ echo "master and development are at the same commit; nothing to back-merge."
42+ exit 0
43+ fi
44+
45+ EXISTING=$(gh pr list --repo "${{ github.repository }}" \
46+ --base development \
47+ --head master \
48+ --state open \
49+ --json number \
50+ --jq 'length')
51+
52+ if [ "$EXISTING" -gt 0 ]; then
53+ echo "An open PR from master to development already exists; skipping."
54+ exit 0
55+ fi
56+
57+ gh pr create --repo "${{ github.repository }}" \
58+ --base development \
59+ --head master \
60+ --title "chore: back-merge master into development" \
61+ --body "Automated back-merge after changes landed on \`master\`. Review and merge to keep \`development\` in sync."
62+
63+ echo "Created back-merge PR master → development."
Original file line number Diff line number Diff line change 88 runs-on : ubuntu-latest
99 steps :
1010 - name : Comment PR
11- if : github.base_ref == 'master' && github.head_ref != 'developement '
11+ if : github.base_ref == 'master' && github.head_ref != 'development '
1212 uses : thollander/actions-comment-pull-request@v2
1313 with :
1414 message : |
You can’t perform that action at this time.
0 commit comments