Skip to content

Commit e5afc18

Browse files
committed
use shared workflows for connection with JIRA
1 parent fc26add commit e5afc18

2 files changed

Lines changed: 8 additions & 86 deletions

File tree

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
1-
# This workflow will create a JIRA issue upon creation of a GitHub issue
2-
31
name: Create JIRA issue
42

53
on:
64
issues:
75
types: [opened]
86

97
jobs:
10-
new_jira_issue:
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- name: JIRA Login
15-
uses: atlassian/gajira-login@v3.0.1
16-
env:
17-
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
18-
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
19-
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
20-
- name: Jira Create issue
21-
id: create_jira_issue
22-
uses: atlassian/gajira-create@v3.0.1
23-
with:
24-
project: GEOPY
25-
issuetype: Story
26-
summary: ${{ github.event.issue.title }}
27-
description: "_from [GitHub issue #${{ github.event.issue.number }}|${{ github.event.issue.html_url }}]_"
28-
# Additional fields in JSON format
29-
fields: '{"components": [{"name": "simpeg"}]}'
30-
- name: Post JIRA link
31-
uses: peter-evans/create-or-update-comment@v3
32-
with:
33-
# The number of the issue or pull request in which to create a comment.
34-
issue-number: ${{ github.event.issue.number }}
35-
# The comment body.
36-
body: "JIRA issue [${{ steps.create_jira_issue.outputs.issue }}] was created."
8+
call-workflow-create-jira-issue:
9+
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-issue_to_jira.yml@main
10+
secrets: inherit
11+
with:
12+
project-key: 'GEOPY'
Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,10 @@
1-
# This workflow will comment the PR with the JIRA issue summary
2-
# if a JIRA issue number is detected in the branch name or title
3-
41
name: Add JIRA issue summary
52

63
on:
74
pull_request_target:
85
types: [opened]
96

107
jobs:
11-
add_jira_summary:
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- name: Find JIRA issue key
16-
id: find_jira_key
17-
env:
18-
HEAD_REF: ${{ github.head_ref}}
19-
PR_TITLE: ${{ github.event.pull_request.title }}
20-
run: >
21-
echo $HEAD_REF $PR_TITLE
22-
| echo "issue_key=$(
23-
grep -osi "\b\(GA\|GEOPY\|DEVOPS\)[ #-]*[0-9]\+"
24-
| head -n1
25-
| sed -E "s/([A-Z]+)[-# ]*([0-9]+)/\1-\2/i"
26-
| tr [:lower:] [:upper:]
27-
)"
28-
>> $GITHUB_OUTPUT
29-
- name: Get JIRA summary
30-
id: get_jira_summary
31-
if: ${{ steps.find_jira_key.outputs.issue_key }}
32-
env:
33-
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
34-
JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }}
35-
run: >
36-
curl -sS -X GET
37-
-H "Authorization: Basic $JIRA_BASIC_AUTH"
38-
-H "Content-Type: application/json"
39-
"$JIRA_BASE_URL/rest/api/2/issue/${{ steps.find_jira_key.outputs.issue_key }}"
40-
| echo "summary=$(jq -r '.fields.summary // empty')" >> $GITHUB_OUTPUT
41-
- name: Extract PR title
42-
id: get_pr_title
43-
env:
44-
PR_TITLE: ${{ github.event.pull_request.title }}
45-
run: |
46-
echo "text=$(echo $PR_TITLE | sed -E "s/^\s*[?[A-Z]+[-# ]*[0-9]+]?[-: ]*(.*)/\1/i")" >> $GITHUB_OUTPUT
47-
- name: Add comment
48-
if: ${{ steps.find_jira_key.outputs.issue_key }}
49-
env:
50-
ISSUE_SUMMARY: ${{ steps.get_jira_summary.outputs.summary }}
51-
TITLE_TEXT: ${{ steps.get_pr_title.outputs.text }}
52-
PR_BODY: ${{ github.event.pull_request.body }}
53-
run: >
54-
jq
55-
--arg ISSUE_ID "${{ steps.find_jira_key.outputs.issue_key }}"
56-
--arg ISSUE_SUMMARY "$(cat <<< $ISSUE_SUMMARY)"
57-
--arg TITLE_TEXT "$(cat <<< ${TITLE_TEXT:-$ISSUE_SUMMARY})"
58-
--arg PR_BODY "$(cat <<< $PR_BODY)"
59-
-c '{"title": ($ISSUE_ID + ": " + $TITLE_TEXT), "body": ("**" + $ISSUE_ID + " - " + $ISSUE_SUMMARY + "**\n" + $PR_BODY)}' <<< {}
60-
| curl -sS -X POST -d @-
61-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
62-
-H "Content-Type: application/json"
63-
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}"
64-
> /dev/null
8+
call-workflow-add-jira-issue-summary:
9+
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-pr_add_jira_summary.yml@main
10+
secrets: inherit

0 commit comments

Comments
 (0)