-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 2.42 KB
/
Copy pathgithub-jira-pr-sync.yml
File metadata and controls
82 lines (69 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# GitHub PR → Jira 동기화
name: PR-Jira Sync
on:
pull_request_target:
types: [ opened ]
branches:
- develop
- main
permissions:
issues: write
contents: read
pull-requests: write
jobs:
sync-pr-to-jira:
runs-on: ubuntu-latest
steps:
- name: Login to Jira
uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
- name: Determine Issue Type
id: issue-type
run: |
TITLE='${{ github.event.pull_request.title }}'
if echo "$TITLE" | grep -qiE "^\[EPIC\]"; then
echo "type=Epic" >> $GITHUB_OUTPUT
elif echo "$TITLE" | grep -qiE "^\[STORY\]"; then
echo "type=Story" >> $GITHUB_OUTPUT
elif echo "$TITLE" | grep -qiE "^fix:|^hotfix:"; then
echo "type=Bug" >> $GITHUB_OUTPUT
else
echo "type=Task" >> $GITHUB_OUTPUT
fi
- name: Convert to Jira Syntax
uses: peter-evans/jira2md@v1
id: md2jira
with:
input-text: |
h3. GitHub PR
${{ github.event.pull_request.html_url }}
h3. Author
${{ github.event.pull_request.user.login }}
h3. Branch
${{ github.head_ref }} -> ${{ github.base_ref }}
----
${{ github.event.pull_request.body }}
mode: md2jira
- name: Create Jira Issue
id: create-jira
uses: atlassian/gajira-create@v3
with:
project: MESP
issuetype: ${{ steps.issue-type.outputs.type }}
summary: '[PR-#${{ github.event.pull_request.number }}] ${{ github.event.pull_request.title }}'
description: '${{ steps.md2jira.outputs.output-text }}'
- name: Add Jira Link Comment
uses: actions/github-script@v7
with:
script: |
const jiraKey = '${{ steps.create-jira.outputs.issue }}';
const jiraUrl = '${{ secrets.JIRA_BASE_URL }}/browse/' + jiraKey;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: `Jira: [${jiraKey}](${jiraUrl})`
});