-
Notifications
You must be signed in to change notification settings - Fork 4
56 lines (45 loc) · 1.55 KB
/
back-merge-pr.yml
File metadata and controls
56 lines (45 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Opens a PR from main → development after changes land on main (back-merge).
name: Back-merge main to development
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
open-back-merge-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Open back-merge PR if needed
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git fetch origin development main
MAIN_SHA=$(git rev-parse origin/main)
DEV_SHA=$(git rev-parse origin/development)
if [ "$MAIN_SHA" = "$DEV_SHA" ]; then
echo "main and development are at the same commit; nothing to back-merge."
exit 0
fi
EXISTING=$(gh pr list --repo "${{ github.repository }}" \
--base development \
--head main \
--state open \
--json number \
--jq 'length')
if [ "$EXISTING" -gt 0 ]; then
echo "An open PR from main to development already exists; skipping."
exit 0
fi
gh pr create --repo "${{ github.repository }}" \
--base development \
--head main \
--title "chore: back-merge main into development" \
--body "Automated back-merge after changes landed on \`main\`. Review and merge to keep \`development\` in sync."
echo "Created back-merge PR main → development."