Skip to content

Commit 58177c7

Browse files
authored
add "Enforce Branch Name Rules" workflow (#4553)
* add "Enforce Branch Name Rules" workflow * whitelist release/* branch names * whitelist dependabot/** branches
1 parent b65574d commit 58177c7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Enforce Branch Name Rules
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
enforce-branch-rules:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check branch name
13+
run: |
14+
echo "Source branch: ${{ github.head_ref }}"
15+
if [[ "${{ github.head_ref }}" != feature/* && \
16+
"${{ github.head_ref }}" != bugfix/* && \
17+
"${{ github.head_ref }}" != release/* && \
18+
"${{ github.head_ref }}" != dependabot/* && \
19+
"${{ github.head_ref }}" != ric/* ]]; then
20+
echo "❌ Pull requests to 'main' are only allowed from 'feature/**', 'bugfix/**', 'release/**', 'dependabot/**', or 'ric/**' branches."
21+
exit 1
22+
fi

0 commit comments

Comments
 (0)