Skip to content

Commit

Permalink
add branch checker
Browse files Browse the repository at this point in the history
  • Loading branch information
divhead committed Jan 1, 2025
1 parent 4e90985 commit 1e85c9a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/check-branch-conventions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check Branch and PR Naming Conventions

on:
pull_request:
branches:
- master
types: [opened, edited, reopened]

jobs:
check-naming:
runs-on: ubuntu-latest

steps:
- name: Check branch and PR title naming conventions
run: |
branch_name="${{ github.event.pull_request.head.ref }}"
pr_title="${{ github.event.pull_request.title }}"
echo "Checking branch name and PR title..."
# Check for Release branches
if [[ "$branch_name" =~ ^release- ]]; then
if [[ ! "$pr_title" =~ ^Release: ]]; then
echo "Error: For 'release-*' branches, PR title must start with 'Release:'."
exit 1
fi
# Check for Hotfix branches
elif [[ "$branch_name" =~ ^hotfix- ]]; then
if [[ ! "$pr_title" =~ ^Hotfix: ]]; then
echo "Error: For 'hotfix-*' branches, PR title must start with 'Hotfix:'."
exit 1
fi
else
echo "Error: Branch must start with 'release-' or 'hotfix-'."
exit 1
fi
echo "Branch and PR title naming conventions are correct."
2 changes: 1 addition & 1 deletion .github/workflows/deploy-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history for all branches
fetch-depth: 0

- name: Configure Git
run: |
Expand Down

0 comments on commit 1e85c9a

Please sign in to comment.