From 72e320c7bd8a2858eaf9b30ef0057e777bc41616 Mon Sep 17 00:00:00 2001 From: Hal Eisen Date: Tue, 6 May 2025 10:42:19 -0700 Subject: [PATCH 1/5] Create check_pr_title.yml --- .github/workflows/check_pr_title.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/check_pr_title.yml diff --git a/.github/workflows/check_pr_title.yml b/.github/workflows/check_pr_title.yml new file mode 100644 index 0000000000..318d48ed20 --- /dev/null +++ b/.github/workflows/check_pr_title.yml @@ -0,0 +1,24 @@ +name: Check PR Title for well-formed Jira issue + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + check_title: + runs-on: ubuntu-latest + steps: + - name: Check PR Title for JIRA Key + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + #!/bin/bash + + jira_regex="ADFA-[0-9]+" + + if [[ "$PR_TITLE" =~ "$jira_regex" ]]; then + echo "PR title '$PR_TITLE' contains a valid JIRA issue key." + else + echo "Error: PR title '$PR_TITLE' does not contain a valid JIRA issue key." + exit 1 + fi From a0bd9ae11d5f681a79ad801d3a19eb99c87e2e52 Mon Sep 17 00:00:00 2001 From: Hal Eisen Date: Tue, 6 May 2025 10:45:04 -0700 Subject: [PATCH 2/5] Update check_pr_title.yml Better error message --- .github/workflows/check_pr_title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_pr_title.yml b/.github/workflows/check_pr_title.yml index 318d48ed20..c47ddb13ca 100644 --- a/.github/workflows/check_pr_title.yml +++ b/.github/workflows/check_pr_title.yml @@ -19,6 +19,6 @@ jobs: if [[ "$PR_TITLE" =~ "$jira_regex" ]]; then echo "PR title '$PR_TITLE' contains a valid JIRA issue key." else - echo "Error: PR title '$PR_TITLE' does not contain a valid JIRA issue key." + echo "Error: PR title '$PR_TITLE' does not contain a valid JIRA issue key. Please ensure your title includes a key in the format ADFA-XXXX." exit 1 fi From f27875defdc446b5549a505a0e3e55048e98b6ee Mon Sep 17 00:00:00 2001 From: Hal Eisen Date: Tue, 6 May 2025 15:19:02 -0700 Subject: [PATCH 3/5] Debug new PR title check --- .github/workflows/check_pr_title.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_pr_title.yml b/.github/workflows/check_pr_title.yml index c47ddb13ca..55788d28ed 100644 --- a/.github/workflows/check_pr_title.yml +++ b/.github/workflows/check_pr_title.yml @@ -15,6 +15,7 @@ jobs: #!/bin/bash jira_regex="ADFA-[0-9]+" + echo "<$jira_regex> <$PR_TITLE>" if [[ "$PR_TITLE" =~ "$jira_regex" ]]; then echo "PR title '$PR_TITLE' contains a valid JIRA issue key." From 2313ed68da4bd0d369e2ff64836cf2a8552de339 Mon Sep 17 00:00:00 2001 From: Hal Eisen Date: Tue, 6 May 2025 15:28:59 -0700 Subject: [PATCH 4/5] Switch from [ (aka test) to grep -q --- .github/workflows/check_pr_title.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check_pr_title.yml b/.github/workflows/check_pr_title.yml index 55788d28ed..daccedb018 100644 --- a/.github/workflows/check_pr_title.yml +++ b/.github/workflows/check_pr_title.yml @@ -16,10 +16,10 @@ jobs: jira_regex="ADFA-[0-9]+" echo "<$jira_regex> <$PR_TITLE>" - - if [[ "$PR_TITLE" =~ "$jira_regex" ]]; then - echo "PR title '$PR_TITLE' contains a valid JIRA issue key." + + if grep -q "$jira_regex" <<< "$PR_TITLE"; then + echo "PR title `$PR_TITLE` contains a valid JIRA issue key." else - echo "Error: PR title '$PR_TITLE' does not contain a valid JIRA issue key. Please ensure your title includes a key in the format ADFA-XXXX." - exit 1 + echo "Error: PR title `$PR_TITLE` does not contain a valid JIRA issue key. Please ensure your title includes a key in the format ADFA-XXXX." + exit 1 fi From e4420b70012bf15a98c9be6bccdfc5abaa2c315f Mon Sep 17 00:00:00 2001 From: Hal Eisen Date: Tue, 6 May 2025 15:30:32 -0700 Subject: [PATCH 5/5] Silly backtick mistake --- .github/workflows/check_pr_title.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_pr_title.yml b/.github/workflows/check_pr_title.yml index daccedb018..1c15d3f888 100644 --- a/.github/workflows/check_pr_title.yml +++ b/.github/workflows/check_pr_title.yml @@ -18,8 +18,8 @@ jobs: echo "<$jira_regex> <$PR_TITLE>" if grep -q "$jira_regex" <<< "$PR_TITLE"; then - echo "PR title `$PR_TITLE` contains a valid JIRA issue key." + echo "PR title '$PR_TITLE' contains a valid JIRA issue key." else - echo "Error: PR title `$PR_TITLE` does not contain a valid JIRA issue key. Please ensure your title includes a key in the format ADFA-XXXX." + echo "Error: PR title '$PR_TITLE' does not contain a valid JIRA issue key. Please ensure your title includes a key in the format ADFA-XXXX." exit 1 fi