From 335d2965fe7a65af47998476409f46057837861c Mon Sep 17 00:00:00 2001 From: E Einowski Date: Fri, 29 Dec 2023 09:54:17 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat(.github/workflows/jira-chec?= =?UTF-8?q?k.yml):=20add=20GitHub=20action=20to=20validate=20PR=20title=20?= =?UTF-8?q?for=20Jira=20ticket=20reference=20A=20new=20GitHub=20action=20h?= =?UTF-8?q?as=20been=20added=20to=20ensure=20that=20each=20PR=20title=20in?= =?UTF-8?q?cludes=20a=20reference=20to=20a=20Jira=20ticket.=20This=20is=20?= =?UTF-8?q?to=20ensure=20that=20all=20changes=20are=20tracked=20against=20?= =?UTF-8?q?a=20specific=20task=20in=20Jira,=20improving=20project=20manage?= =?UTF-8?q?ment=20and=20traceability.=20The=20action=20triggers=20on=20PR?= =?UTF-8?q?=20events=20such=20as=20opening,=20editing,=20reopening,=20and?= =?UTF-8?q?=20synchronizing.=20If=20the=20PR=20title=20does=20not=20follow?= =?UTF-8?q?=20the=20required=20format=20'[CMP-xxxx]=20Title',=20the=20acti?= =?UTF-8?q?on=20will=20fail=20and=20provide=20an=20error=20message=20instr?= =?UTF-8?q?ucting=20the=20user=20to=20update=20the=20title.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/jira-check.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/jira-check.yml diff --git a/.github/workflows/jira-check.yml b/.github/workflows/jira-check.yml new file mode 100644 index 0000000..a1e33df --- /dev/null +++ b/.github/workflows/jira-check.yml @@ -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 }}