|
1 | 1 | name: Create Jira Issue |
2 | 2 | on: |
3 | | - issues: |
4 | | - types: |
5 | | - - opened |
| 3 | + issues: |
| 4 | + types: |
| 5 | + - opened |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - create-issue: |
9 | | - name: Create Jira issue |
10 | | - runs-on: ubuntu-latest |
11 | | - |
12 | | - steps: |
13 | | - - name: Determine Issue Type |
14 | | - id: type |
15 | | - run: | |
16 | | - if echo "${{ toJson(github.event.issue.labels) }}" | grep -q '✨ feat'; then |
17 | | - echo "type=feature" >> $GITHUB_OUTPUT |
18 | | - echo "template=feature-task.yml" >> $GITHUB_OUTPUT |
19 | | - elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '🐞 fix'; then |
20 | | - echo "type=fix" >> $GITHUB_OUTPUT |
21 | | - echo "template=fix-task.yml" >> $GITHUB_OUTPUT |
22 | | - elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '🔨 refactor'; then |
23 | | - echo "type=refactor" >> $GITHUB_OUTPUT |
24 | | - echo "template=refactor-task.yml" >> $GITHUB_OUTPUT |
25 | | - elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '📃 docs'; then |
26 | | - echo "type=docs" >> $GITHUB_OUTPUT |
27 | | - echo "template=docs-task.yml" >> $GITHUB_OUTPUT |
28 | | - elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '⚙️ chore'; then |
29 | | - echo "type=chore" >> $GITHUB_OUTPUT |
30 | | - echo "template=chore-task.yml" >> $GITHUB_OUTPUT |
31 | | - elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '✅ test'; then |
32 | | - echo "type=test" >> $GITHUB_OUTPUT |
33 | | - echo "template=test-task.yml" >> $GITHUB_OUTPUT |
34 | | - else |
35 | | - echo "type=feature" >> $GITHUB_OUTPUT |
36 | | - echo "template=feature-task.yml" >> $GITHUB_OUTPUT |
37 | | - fi |
38 | | -
|
39 | | - - name: Clean Issue Title (for Jira Summary) |
40 | | - id: clean |
41 | | - run: | |
42 | | - raw="${{ github.event.issue.title }}" |
43 | | - # Remove prefix like 'feat]', 'fix]', 'chore]', etc. |
44 | | - clean_title=$(echo "$raw" | sed -E 's/^[a-z]+\]\s*//I') |
45 | | - echo "title=$clean_title" >> $GITHUB_OUTPUT |
46 | | -
|
47 | | - - name: Jira Login |
48 | | - uses: atlassian/gajira-login@v3 |
49 | | - env: |
50 | | - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} |
51 | | - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} |
52 | | - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} |
53 | | - |
54 | | - - name: Checkout main code |
55 | | - uses: actions/checkout@v4 |
56 | | - with: |
57 | | - ref: develop |
58 | | - |
59 | | - - name: Parse Issue |
60 | | - uses: stefanbuck/github-issue-parser@v3 |
61 | | - id: issue-parser |
62 | | - with: |
63 | | - template-path: .github/ISSUE_TEMPLATE/${{ steps.type.outputs.template }} |
64 | | - |
65 | | - - name: Convert markdown to Jira Syntax |
66 | | - uses: peter-evans/jira2md@v1 |
67 | | - id: md2jira |
68 | | - with: |
69 | | - input-text: | |
70 | | - ### Github Issue Link |
71 | | - - ${{ github.event.issue.html_url }} |
72 | | -
|
73 | | - ### 기능 설명 |
74 | | - ${{ steps.issue-parser.outputs.issueparser_description }} |
75 | | -
|
76 | | - ### 작업 목록 |
77 | | - ${{ steps.issue-parser.outputs.issueparser_tasks }} |
78 | | -
|
79 | | - ### 참고 링크 |
80 | | - ${{ steps.issue-parser.outputs.issueparser_links }} |
81 | | - mode: md2jira |
82 | | - |
83 | | - - name: Create Issue |
84 | | - id: create |
85 | | - uses: atlassian/gajira-create@v3 |
86 | | - with: |
87 | | - project: BOOK |
88 | | - issuetype: 하위 작업 |
89 | | - summary: '${{ steps.clean.outputs.title }}' |
90 | | - description: '${{ steps.md2jira.outputs.output-text }}' |
91 | | - fields: | |
92 | | - { |
93 | | - "parent": { |
94 | | - "key": "${{ steps.issue-parser.outputs.issueparser_parentKey }}" |
95 | | - } |
96 | | - } |
97 | | -
|
98 | | - - name: Checkout both branches |
99 | | - uses: actions/checkout@v4 |
100 | | - with: |
101 | | - fetch-depth: 0 |
102 | | - |
103 | | - - name: Switch to develop |
104 | | - run: | |
105 | | - git fetch origin develop |
106 | | - git checkout develop |
107 | | -
|
108 | | - - name: Generate Branch Name |
109 | | - id: branch |
110 | | - run: | |
111 | | - issue_number=${{ github.event.issue.number }} |
112 | | - issue_title="${{ github.event.issue.title }}" |
113 | | - slug=$(echo "$issue_title" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/[^a-z0-9\-]//g') |
114 | | - ticket_key="${{ steps.create.outputs.issue }}" |
115 | | - branch_name="${ticket_key}-${{ steps.type.outputs.type }}/#${issue_number}" |
116 | | - echo "branch=${branch_name}" >> $GITHUB_OUTPUT |
117 | | -
|
118 | | - - name: Create and push branch |
119 | | - run: | |
120 | | - git config user.name "github-actions[bot]" |
121 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
122 | | - git checkout -b "${{ steps.branch.outputs.branch }}" |
123 | | - git push origin "${{ steps.branch.outputs.branch }}" |
124 | | -
|
125 | | - - name: Update issue title |
126 | | - uses: actions-cool/issues-helper@v3 |
127 | | - with: |
128 | | - actions: 'update-issue' |
129 | | - token: ${{ secrets.PAT_TOKEN }} |
130 | | - title: '[${{ steps.create.outputs.issue }}/${{ github.event.issue.title }}' |
131 | | - |
132 | | - - name: Add comment with Jira issue link |
133 | | - uses: actions-cool/issues-helper@v3 |
134 | | - with: |
135 | | - actions: 'create-comment' |
136 | | - token: ${{ secrets.PAT_TOKEN }} |
137 | | - issue-number: ${{ github.event.issue.number }} |
138 | | - body: 'Jira Issue Created: [${{ steps.create.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create.outputs.issue }})' |
139 | | - |
140 | | - - name: Add comment with Branch Name |
141 | | - uses: actions-cool/issues-helper@v3 |
142 | | - with: |
143 | | - actions: 'create-comment' |
144 | | - token: ${{ secrets.PAT_TOKEN }} |
145 | | - issue-number: ${{ github.event.issue.number }} |
146 | | - body: '🔀 Branch Created: `${{ steps.branch.outputs.branch }}`' |
147 | | - |
148 | | - - name: Assign issue author |
149 | | - uses: actions-cool/issues-helper@v3 |
150 | | - with: |
151 | | - actions: 'add-assignees' |
152 | | - token: ${{ secrets.PAT_TOKEN }} |
153 | | - issue-number: ${{ github.event.issue.number }} |
154 | | - assignees: ${{ github.event.issue.user.login }} |
| 8 | + create-issue: |
| 9 | + # qa 라벨이 없을 때만 Jira issue 생성 |
| 10 | + if: contains(github.event.issue.labels.*.name, 'qa') == false |
| 11 | + name: Create Jira issue |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Determine Issue Type |
| 16 | + id: type |
| 17 | + run: | |
| 18 | + if echo "${{ toJson(github.event.issue.labels) }}" | grep -q '✨ feat'; then |
| 19 | + echo "type=feature" >> $GITHUB_OUTPUT |
| 20 | + echo "template=feature-task.yml" >> $GITHUB_OUTPUT |
| 21 | + elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '🐞 fix'; then |
| 22 | + echo "type=fix" >> $GITHUB_OUTPUT |
| 23 | + echo "template=fix-task.yml" >> $GITHUB_OUTPUT |
| 24 | + elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '🔨 refactor'; then |
| 25 | + echo "type=refactor" >> $GITHUB_OUTPUT |
| 26 | + echo "template=refactor-task.yml" >> $GITHUB_OUTPUT |
| 27 | + elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '📃 docs'; then |
| 28 | + echo "type=docs" >> $GITHUB_OUTPUT |
| 29 | + echo "template=docs-task.yml" >> $GITHUB_OUTPUT |
| 30 | + elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '⚙️ chore'; then |
| 31 | + echo "type=chore" >> $GITHUB_OUTPUT |
| 32 | + echo "template=chore-task.yml" >> $GITHUB_OUTPUT |
| 33 | + elif echo "${{ toJson(github.event.issue.labels) }}" | grep -q '✅ test'; then |
| 34 | + echo "type=test" >> $GITHUB_OUTPUT |
| 35 | + echo "template=test-task.yml" >> $GITHUB_OUTPUT |
| 36 | + else |
| 37 | + echo "type=feature" >> $GITHUB_OUTPUT |
| 38 | + echo "template=feature-task.yml" >> $GITHUB_OUTPUT |
| 39 | + fi |
| 40 | +
|
| 41 | + - name: Clean Issue Title (for Jira Summary) |
| 42 | + id: clean |
| 43 | + run: | |
| 44 | + raw="${{ github.event.issue.title }}" |
| 45 | + # Remove prefix like 'feat]', 'fix]', 'chore]', etc. |
| 46 | + clean_title=$(echo "$raw" | sed -E 's/^[a-z]+\]\s*//I') |
| 47 | + echo "title=$clean_title" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Jira Login |
| 50 | + uses: atlassian/gajira-login@v3 |
| 51 | + env: |
| 52 | + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} |
| 53 | + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} |
| 54 | + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} |
| 55 | + |
| 56 | + - name: Checkout main code |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + ref: develop |
| 60 | + |
| 61 | + - name: Parse Issue |
| 62 | + uses: stefanbuck/github-issue-parser@v3 |
| 63 | + id: issue-parser |
| 64 | + with: |
| 65 | + template-path: .github/ISSUE_TEMPLATE/${{ steps.type.outputs.template }} |
| 66 | + |
| 67 | + - name: Convert markdown to Jira Syntax |
| 68 | + uses: peter-evans/jira2md@v1 |
| 69 | + id: md2jira |
| 70 | + with: |
| 71 | + input-text: | |
| 72 | + ### Github Issue Link |
| 73 | + - ${{ github.event.issue.html_url }} |
| 74 | +
|
| 75 | + ### 기능 설명 |
| 76 | + ${{ steps.issue-parser.outputs.issueparser_description }} |
| 77 | +
|
| 78 | + ### 작업 목록 |
| 79 | + ${{ steps.issue-parser.outputs.issueparser_tasks }} |
| 80 | +
|
| 81 | + ### 참고 링크 |
| 82 | + ${{ steps.issue-parser.outputs.issueparser_links }} |
| 83 | + mode: md2jira |
| 84 | + |
| 85 | + - name: Create Issue |
| 86 | + id: create |
| 87 | + uses: atlassian/gajira-create@v3 |
| 88 | + with: |
| 89 | + project: BOOK |
| 90 | + issuetype: 하위 작업 |
| 91 | + summary: '${{ steps.clean.outputs.title }}' |
| 92 | + description: '${{ steps.md2jira.outputs.output-text }}' |
| 93 | + fields: | |
| 94 | + { |
| 95 | + "parent": { |
| 96 | + "key": "${{ steps.issue-parser.outputs.issueparser_parentKey }}" |
| 97 | + } |
| 98 | + } |
| 99 | +
|
| 100 | + - name: Checkout both branches |
| 101 | + uses: actions/checkout@v4 |
| 102 | + with: |
| 103 | + fetch-depth: 0 |
| 104 | + |
| 105 | + - name: Switch to develop |
| 106 | + run: | |
| 107 | + git fetch origin develop |
| 108 | + git checkout develop |
| 109 | +
|
| 110 | + - name: Generate Branch Name |
| 111 | + id: branch |
| 112 | + run: | |
| 113 | + issue_number=${{ github.event.issue.number }} |
| 114 | + issue_title="${{ github.event.issue.title }}" |
| 115 | + slug=$(echo "$issue_title" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g' | sed 's/[^a-z0-9\-]//g') |
| 116 | + ticket_key="${{ steps.create.outputs.issue }}" |
| 117 | + branch_name="${ticket_key}-${{ steps.type.outputs.type }}/#${issue_number}" |
| 118 | + echo "branch=${branch_name}" >> $GITHUB_OUTPUT |
| 119 | +
|
| 120 | + - name: Create and push branch |
| 121 | + run: | |
| 122 | + git config user.name "github-actions[bot]" |
| 123 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 124 | + git checkout -b "${{ steps.branch.outputs.branch }}" |
| 125 | + git push origin "${{ steps.branch.outputs.branch }}" |
| 126 | +
|
| 127 | + - name: Update issue title |
| 128 | + uses: actions-cool/issues-helper@v3 |
| 129 | + with: |
| 130 | + actions: 'update-issue' |
| 131 | + token: ${{ secrets.PAT_TOKEN }} |
| 132 | + title: '[${{ steps.create.outputs.issue }}/${{ github.event.issue.title }}' |
| 133 | + |
| 134 | + - name: Add comment with Jira issue link |
| 135 | + uses: actions-cool/issues-helper@v3 |
| 136 | + with: |
| 137 | + actions: 'create-comment' |
| 138 | + token: ${{ secrets.PAT_TOKEN }} |
| 139 | + issue-number: ${{ github.event.issue.number }} |
| 140 | + body: 'Jira Issue Created: [${{ steps.create.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create.outputs.issue }})' |
| 141 | + |
| 142 | + - name: Add comment with Branch Name |
| 143 | + uses: actions-cool/issues-helper@v3 |
| 144 | + with: |
| 145 | + actions: 'create-comment' |
| 146 | + token: ${{ secrets.PAT_TOKEN }} |
| 147 | + issue-number: ${{ github.event.issue.number }} |
| 148 | + body: '🔀 Branch Created: `${{ steps.branch.outputs.branch }}`' |
| 149 | + |
| 150 | + - name: Assign issue author |
| 151 | + uses: actions-cool/issues-helper@v3 |
| 152 | + with: |
| 153 | + actions: 'add-assignees' |
| 154 | + token: ${{ secrets.PAT_TOKEN }} |
| 155 | + issue-number: ${{ github.event.issue.number }} |
| 156 | + assignees: ${{ github.event.issue.user.login }} |
0 commit comments