Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirrorgo authored Aug 16, 2024
2 parents 494428d + 93c0ce2 commit d945c84
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Merge Protection

on:
pull_request:
branches: [main, release, doc]

jobs:
check-branch-rules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Check branch merge rules
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
base_branch="${{ github.base_ref }}"
head_branch="${{ github.head_ref }}"
case $base_branch in
main)
if [[ $head_branch != "release" && $head_branch != "doc" ]]; then
echo "Error: main can only be merged from release or doc branches."
exit 1
fi
;;
release)
if [[ $head_branch != feature/* ]]; then
echo "Error: release can only be merged from feature/* branches."
exit 1
fi
;;
doc)
echo "Error: doc branch cannot be merged from any other branch."
exit 1
;;
*)
if [[ $head_branch == test/* ]]; then
echo "Error: test/ branches cannot be merged into any other branch."
exit 1
fi
;;
esac
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
- name: Prevent merge
run: |
echo "Branch merge rules check failed. Preventing merge."
exit 1
exit 1

0 comments on commit d945c84

Please sign in to comment.