Skip to content

Commit eea733b

Browse files
committed
add CI action that requires clean merges between all named branches
1 parent 7adb0a2 commit eea733b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Require Clean Merges
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- devnet-ready
7+
- devnet
8+
- testnet
9+
10+
jobs:
11+
assert-clean-merges:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Ensures we get all branches for merging
18+
19+
- name: Determine Target Branch and Set Merge List
20+
id: set-merge-branches
21+
run: |
22+
TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
23+
if [[ "$TARGET_BRANCH" == "devnet-ready" ]]; then
24+
echo "MERGE_BRANCHES=devnet-ready devnet testnet main" >> $GITHUB_ENV
25+
elif [[ "$TARGET_BRANCH" == "devnet" ]]; then
26+
echo "MERGE_BRANCHES=devnet testnet main" >> $GITHUB_ENV
27+
elif [[ "$TARGET_BRANCH" == "testnet" ]]; then
28+
echo "MERGE_BRANCHES=testnet main" >> $GITHUB_ENV
29+
elif [[ "$TARGET_BRANCH" == "main" ]]; then
30+
echo "MERGE_BRANCHES=main" >> $GITHUB_ENV
31+
else
32+
echo "MERGE_BRANCHES=devnet-ready devnet testnet main" >> $GITHUB_ENV"
33+
fi
34+
35+
- name: Check Merge Cleanliness
36+
run: |
37+
for branch in $MERGE_BRANCHES; do
38+
echo "Checking merge from $branch into ${{ github.event.pull_request.base.ref }}..."
39+
git fetch origin $branch
40+
git checkout ${{ github.event.pull_request.base.ref }}
41+
if ! git merge --no-commit --no-ff origin/$branch; then
42+
echo "Merge conflict detected when merging $branch into ${{ github.event.pull_request.base.ref }}"
43+
exit 1
44+
fi
45+
git merge --abort
46+
done

0 commit comments

Comments
 (0)