Skip to content

Commit

Permalink
branch name validators
Browse files Browse the repository at this point in the history
  • Loading branch information
jagankumar-egov authored Oct 23, 2024
1 parent 6564f90 commit 87190fe
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Bugfix Request

#### JIRA ID
<!-- Provide a detailed description of the feature -->

#### Module
<!-- Provide a detailed description of the feature -->

#### Description
<!-- Provide a detailed description of the feature -->

#### Related Issues
<!-- Link any related GitHub issues here -->
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Feature Request

#### JIRA ID
<!-- Provide a detailed description of the feature -->

#### Module
<!-- Provide a detailed description of the feature -->

#### Description
<!-- Provide a detailed description of the feature -->

#### Related Issues
<!-- Link any related GitHub issues here -->
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Release Request

#### JIRA ID
<!-- Provide a detailed description of the feature -->

#### Module
<!-- Provide a detailed description of the feature -->

#### Description
<!-- Provide a detailed description of the feature -->

#### List of Features
<!-- Link any related GitHub issues here -->

#### List of Issues
<!-- Link any related GitHub issues here -->
25 changes: 25 additions & 0 deletions .github/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# Get the current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

# Define the pattern
PATTERN="^(FEATURE|BUGFIX|RELEASE)\/(HCMPRE|DPG|SN)-[0-9]{1,5}$"

# Check if the branch name matches the pattern
if [[ ! "$BRANCH_NAME" =~ $PATTERN ]]; then
echo "Branch name '$BRANCH_NAME' does not follow the correct pattern:"
echo " - FEATURE/HCMPRE-<TICKET_NO>"
echo " - FEATURE/DPG-<TICKET_NO>"
echo " - FEATURE/SN-<TICKET_NO>"
echo " - BUGFIX/HCMPRE-<TICKET_NO>"
echo " - BUGFIX/DPG-<TICKET_NO>"
echo " - BUGFIX/SN-<TICKET_NO>"
echo " - RELEASE/HCMPRE-<TICKET_NO>"
echo " - RELEASE/DPG-<TICKET_NO>"
echo "Where <TICKET_NO> is a number between 0 and 99999."
exit 1
fi

# If the pattern matches, allow the push
exit 0
27 changes: 27 additions & 0 deletions .github/workflows/branch-name-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Branch Name Validation

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
validate-branch-name:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Validate branch name
run: |
branch_name=$(echo "${GITHUB_REF#refs/heads/}")
pattern="^(FEATURE|BUGFIX|RELEASE)\/(HCMPRE|DPG|SN)-[0-9]{1,5}$"
if [[ ! "$branch_name" =~ $pattern ]]; then
echo "Branch name '$branch_name' does not follow the correct pattern: FEATURE/HCMPRE-<TICKET_NO>, FEATURE/DPG-<TICKET_NO>, FEATURE/SN-<TICKET_NO>, BUGFIX/SN-<TICKET_NO>, BUGFIX/HCMPRE-<TICKET_NO>, or BUGFIX/DPG-<TICKET_NO> where x is a number between 0 and 99999"
exit 1
fi

0 comments on commit 87190fe

Please sign in to comment.