From 8de72a636d4191a25305038d39737c3826de6457 Mon Sep 17 00:00:00 2001 From: andrewg-mira <89816284+andrewg-mira@users.noreply.github.com> Date: Tue, 10 Mar 2026 11:56:05 -0700 Subject: [PATCH] DEVOPS-989 use reusable pr_jira_actions workflow --- .github/workflows/pr_add_jira_summary.yml | 64 ----------------------- .github/workflows/pr_jira_actions.yml | 16 ++++++ 2 files changed, 16 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/pr_add_jira_summary.yml create mode 100644 .github/workflows/pr_jira_actions.yml diff --git a/.github/workflows/pr_add_jira_summary.yml b/.github/workflows/pr_add_jira_summary.yml deleted file mode 100644 index f0c8a8dda..000000000 --- a/.github/workflows/pr_add_jira_summary.yml +++ /dev/null @@ -1,64 +0,0 @@ -# This workflow will comment the PR with the JIRA issue summary -# if a JIRA issue number is detected in the branch name or title - -name: Add JIRA issue summary - -on: - pull_request_target: - types: [opened] - -jobs: - add_jira_summary: - runs-on: ubuntu-latest - - steps: - - name: Find JIRA issue key - id: find_jira_key - env: - HEAD_REF: ${{ github.head_ref}} - PR_TITLE: ${{ github.event.pull_request.title }} - run: > - echo $HEAD_REF $PR_TITLE - | echo "issue_key=$( - grep -osi "\b\(GA\|GEOPY\|DEVOPS\)[ #-]*[0-9]\+" - | head -n1 - | sed -E "s/([A-Z]+)[-# ]*([0-9]+)/\1-\2/i" - | tr [:lower:] [:upper:] - )" - >> $GITHUB_OUTPUT - - name: Get JIRA summary - id: get_jira_summary - if: ${{ steps.find_jira_key.outputs.issue_key }} - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }} - run: > - curl -sS -X GET - -H "Authorization: Basic $JIRA_BASIC_AUTH" - -H "Content-Type: application/json" - "$JIRA_BASE_URL/rest/api/2/issue/${{ steps.find_jira_key.outputs.issue_key }}" - | echo "summary=$(jq -r '.fields.summary // empty')" >> $GITHUB_OUTPUT - - name: Extract PR title - id: get_pr_title - env: - PR_TITLE: ${{ github.event.pull_request.title }} - run: | - echo "text=$(echo $PR_TITLE | sed -E "s/^\s*[?[A-Z]+[-# ]*[0-9]+]?[-: ]*(.*)/\1/i")" >> $GITHUB_OUTPUT - - name: Add comment - if: ${{ steps.find_jira_key.outputs.issue_key }} - env: - ISSUE_SUMMARY: ${{ steps.get_jira_summary.outputs.summary }} - TITLE_TEXT: ${{ steps.get_pr_title.outputs.text }} - PR_BODY: ${{ github.event.pull_request.body }} - run: > - jq - --arg ISSUE_ID "${{ steps.find_jira_key.outputs.issue_key }}" - --arg ISSUE_SUMMARY "$(cat <<< $ISSUE_SUMMARY)" - --arg TITLE_TEXT "$(cat <<< ${TITLE_TEXT:-$ISSUE_SUMMARY})" - --arg PR_BODY "$(cat <<< $PR_BODY)" - -c '{"title": ($ISSUE_ID + ": " + $TITLE_TEXT), "body": ("**" + $ISSUE_ID + " - " + $ISSUE_SUMMARY + "**\n" + $PR_BODY)}' <<< {} - | curl -sS -X POST -d @- - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" - -H "Content-Type: application/json" - "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}" - > /dev/null diff --git a/.github/workflows/pr_jira_actions.yml b/.github/workflows/pr_jira_actions.yml new file mode 100644 index 000000000..4fa28f89a --- /dev/null +++ b/.github/workflows/pr_jira_actions.yml @@ -0,0 +1,16 @@ +name: JIRA actions + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + call-workflow-pr_jira_actions: + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-pr_actions.yml@v3 + permissions: + contents: read + pull-requests: write + secrets: + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}