Skip to content

Commit

Permalink
🎉 feat(.github/workflows/jira-check.yml): add GitHub action to valida…
Browse files Browse the repository at this point in the history
…te PR title for Jira ticket reference

A new GitHub action has been added to ensure that each PR title includes a reference to a Jira ticket. This is to ensure that all changes are tracked against a specific task in Jira, improving project management and traceability. The action triggers on PR events such as opening, editing, reopening, and synchronizing. If the PR title does not follow the required format '[CMP-xxxx] Title', the action will fail and provide an error message instructing the user to update the title.
  • Loading branch information
EwiththeBowtie committed Dec 29, 2023
1 parent 52646d5 commit 335d296
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/jira-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PR Title Jira Ticket Check

on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
check-pr-title:
name: Ensure Jira Ticket
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Check PR title for Jira Ticket
run: |
PR_TITLE=$(jq -r .pull_request.title "$GITHUB_EVENT_PATH")
if ! [[ "$PR_TITLE" =~ CMP-[0-9]+ ]]; then
echo "Please change the PR title to '[CMP-xxxx] $PR_TITLE' to indicate the jira ticket the PR is associated with." >> $GITHUB_STEP_SUMMARY
echo "## :error: Error in PR Title" >> $GITHUB_STEP_SUMMARY
echo "The PR title does not follow the required format '[CMP-xxxx] Title'. Please update the title to include the associated JIRA ticket." >> $GITHUB_STEP_SUMMARY
exit 1
fi
env:
GITHUB_EVENT_PATH: ${{ github.event_path }}

0 comments on commit 335d296

Please sign in to comment.