-
Notifications
You must be signed in to change notification settings - Fork 6
33 lines (30 loc) · 973 Bytes
/
branch_naming_policy.yml
File metadata and controls
33 lines (30 loc) · 973 Bytes
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
name: Branch Naming Policy
on:
create:
pull_request:
branches:
- master
types:
- opened
- reopened
jobs:
branch-naming-policy:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Branch naming policy check
run: |
echo "${{ steps.extract_branch.outputs.branch }}"
[[ "${{ steps.extract_branch.outputs.branch }}" =~ ^(feature|bugfix|hotfix|docs|refactor)/[a-z0-9_]{5,50}$ ]] || exit 1
- name: Close pull request and delete branch
if: failure()
env:
PR_NUMBER: ${{ github.event.number }}
GH_TOKEN: ${{ github.token }}
run: |
gh pr close "$PR_NUMBER" -c "Pull request has been closed due the breach of branch naming policy" -d