Skip to content

Commit 25fbda3

Browse files
rubenvdlindeclaude
andcommitted
Update branch protection: main from beta, beta from development
Enforce that PRs to main can only come from beta or hotfix branches, and PRs to beta can only come from development or hotfix branches. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4bd734b commit 25fbda3

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
name: Main Branch Protection
1+
name: Branch Protection
22

33
on:
44
pull_request:
55
branches:
66
- main
7+
- beta
78

89
jobs:
910
check-branch:
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Check branch
1314
run: |
14-
if [[ ${GITHUB_HEAD_REF} != development ]] && [[ ${GITHUB_HEAD_REF} != documentation ]] && ! [[ ${GITHUB_HEAD_REF} =~ ^hotfix/ ]];
15-
then
16-
echo "Error: Pull request must come from 'development', 'documentation' or 'hotfix/' branch"
17-
exit 1
15+
TARGET="${{ github.base_ref }}"
16+
SOURCE="${{ github.head_ref }}"
17+
18+
if [[ "$TARGET" == "main" ]]; then
19+
if [[ "$SOURCE" != "beta" ]] && ! [[ "$SOURCE" =~ ^hotfix ]]; then
20+
echo "Error: Pull requests to main must come from 'beta' or a branch starting with 'hotfix'"
21+
echo "Source branch: $SOURCE"
22+
exit 1
23+
fi
24+
elif [[ "$TARGET" == "beta" ]]; then
25+
if [[ "$SOURCE" != "development" ]] && ! [[ "$SOURCE" =~ ^hotfix ]]; then
26+
echo "Error: Pull requests to beta must come from 'development' or a branch starting with 'hotfix'"
27+
echo "Source branch: $SOURCE"
28+
exit 1
29+
fi
1830
fi
31+
32+
echo "Branch check passed: $SOURCE -> $TARGET"

0 commit comments

Comments
 (0)