-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
67 lines (59 loc) · 2.23 KB
/
action.yml
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
name: 'Add Jira task comment'
description: 'add a jira task comment'
inputs:
prefix:
description: 'Comment Body Prefix'
required: false
default: ''
suffix:
description: 'Comment Body Suffix'
required: false
default: ''
regexp:
description: 'Task Pattern RegExp'
required: false
default: '(proxy|lan|com|travel)(\\s|-)(\\d+)'
runs:
using: "composite"
steps:
- name: Get PR title
id: get-pr-title
shell: bash
run: echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
- name: Find jira task and make comment body
id: find-jira-task
uses: actions/github-script@v6
with:
script: |
const taskRegexp = new RegExp(`${{ inputs.regexp }}`, 'gi');
const result = `${{ steps.get-pr-title.outputs.title }}`.match(taskRegexp);
if(!result){
core.notice('Not Found Matched Task Pattern')
return;
}
const jiraURL = 'https://creatrip.atlassian.net/browse/'
const taskId = result[0].replace(" ", "-");
const commentBody = `${{ inputs.prefix }}[지라 태스크 URL](${jiraURL + taskId})${{ inputs.suffix }}`
core.setOutput('body', commentBody)
core.setOutput('taskId', taskId)
- name: Find Comment
uses: peter-evans/find-comment@v2
if: github.event.number && steps.find-jira-task.outputs.body
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: ${{ steps.find-jira-task.outputs.taskId }}
- name: Create Comment
uses: peter-evans/create-or-update-comment@v2
if: success() && github.event.number && steps.fc.outputs.comment-id == 0 && steps.find-jira-task.outputs.body
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.find-jira-task.outputs.body }}
- name: Update Comment
uses: peter-evans/create-or-update-comment@v2
if: success() && github.event.number && steps.fc.outputs.comment-id != 0 && steps.find-jira-task.outputs.body
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.find-jira-task.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace