Skip to content

chore: more updates to contributor, validation, and qa workflows #4

chore: more updates to contributor, validation, and qa workflows

chore: more updates to contributor, validation, and qa workflows #4

# This workflow validates that branch and commit names are standardized for better workflow.
name: Validation Workflow
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
validate-branch-name:
runs-on: ubuntu-latest
steps:
- name: Extract and Validate Branch Name
run: |
set -euo pipefail
echo "Validating branch name..."
BRANCH_NAME="${{ github.ref_name }}"
echo "Branch name: $BRANCH_NAME"
if [[ "$BRANCH_NAME" =~ ^(qa|beta|main)$ ]]; then
echo "✅ Branch name '$BRANCH_NAME' is valid for protected branches (qa, beta, main)."
elif [[ "$BRANCH_NAME" =~ ^(feat|fix|hotfix|chore|test|refactor|release)/[a-z0-9_-]+$ ]]; then
echo "✅ Branch name '$BRANCH_NAME' follows the naming convention."
else
echo "❌ Branch name '$BRANCH_NAME' does not follow the naming convention: <type>/<branch-name>"
echo "Valid types: feat, fix, hotfix, chore, test, refactor, release, qa, beta, main"
exit 1
fi
validate-commit-messages:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Validate Commit Messages
run: |
set -euo pipefail
echo "Validating commit messages..."
REGEX="^(feat|fix|hotfix|chore|test|refactor|release)(\\([a-z0-9_-]+\\))?: .{1,72}$"
INVALID_COMMITS=$(git log --format=%s HEAD | grep -vE "$REGEX" || true)
if [[ -n "$INVALID_COMMITS" ]]; then
echo "❌ The following commit messages do not follow the convention:"
echo "$INVALID_COMMITS"
echo ""
echo "Commit message format must follow:"
echo "<type>(<scope>): <short summary>"
echo "Examples:"
echo " feat(auth): add OAuth 2.0 support"
echo " fix(payment): resolve rounding error in total calculation"
exit 1
else
echo "✅ All commit messages follow the convention."
fi