feat: DAH-3122 Log Potential Google Translate API Usage #186
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate PR Title | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
jobs: | |
check-title: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Validate PR title | |
env: | |
PR_TITLE: ${{ github.event.pull_request.title }} | |
run: | | |
# Define the regex for the required formats | |
jira_regex="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test): DAH-[0-9]+ .+" | |
urgent_regex="^urgent: \S+" | |
if [[ "${PR_TITLE}" =~ $urgent_regex ]]; then | |
echo "PR title contains 'urgent'. Skipping JIRA check but validating description." | |
elif [[ "${PR_TITLE}" =~ $jira_regex ]]; then | |
echo "PR title matches JIRA format." | |
exit 0 | |
else | |
echo "Invalid PR title: '${PR_TITLE}'" | |
echo "Please format your PR title as:" | |
echo "'<label>: DAH-<issue number> <description>'" | |
echo "or use 'urgent: <description>' for urgent PRs." | |
echo "Available labels (case sensitive): build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test." | |
echo "Examples:" | |
echo "- 'feat: DAH-1234 Add new feature'" | |
echo "- 'urgent: Hotfix for production'" | |
exit 1 | |
fi | |
# Validate that a description exists and has no trailing whitespace | |
description_regex="^.*: \S+" | |
if [[ ! "${PR_TITLE}" =~ $description_regex ]]; then | |
echo "Missing or invalid description in PR title: '${PR_TITLE}'" | |
echo "Ensure your PR title includes a description after the colon with no extra whitespace." | |
exit 1 | |
fi | |
echo "PR title is valid." |