diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8ef194855f..4d5064214d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,7 +12,7 @@ https://sfgovdt.jira.com/browse/ - [ ] branch name begins with `angular` if it contains updates to Angular code - [ ] branch name contains the Jira ticket number -- [ ] PR name follows `type: TICKET-NUMBER Description` format, e.g. `feat: DAH-123 New Feature` +- [ ] PR name follows `type: TICKET-NUMBER Description` format, e.g. `feat: DAH-123 New Feature`. If the PR is urgent and does not need a ticket then use the format `urgent: Description` ### Code quality @@ -32,4 +32,4 @@ https://sfgovdt.jira.com/browse/ - [ ] PR has `needs review` label - [ ] Use `Housing Eng` group to automatically assign reviewers, and/or assign specific engineers -- [ ] If time sensitive, notify engineers in Slack \ No newline at end of file +- [ ] If time sensitive, notify engineers in Slack diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml new file mode 100644 index 0000000000..2ef976338a --- /dev/null +++ b/.github/workflows/pr-title-check.yml @@ -0,0 +1,47 @@ +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 "'