Create Jira issue #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Jira issue | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
create-issue: | |
name: Create Jira issue | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login | |
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: Process Issue Body | |
id: process_body | |
run: | | |
BODY=$(echo '${{ github.event.issue.body }}' | perl -0pe 's/<!--[\s\S]*?-->//g' | sed 's/^## 💥 이슈 설명/h2. 💥 이슈 설명/g' | sed 's/^## 📚 TO-DO/h2. 📚 TO-DO/g' | sed 's/^## 👀 참고 사항/h2. 👀 참고 사항/g' | sed 's/^- \[ \] /* /g' | sed 's/^ - \[ \] /** /g' | sed 's/^ - \[ \] /*** /g') | |
echo "processed_body<<EOF" >> $GITHUB_OUTPUT | |
echo "$BODY" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Create Issue | |
id: create | |
uses: atlassian/gajira-create@v3 | |
with: | |
project: ISSUE | |
issuetype: Task | |
summary: '${{ github.event.issue.title }}' | |
description: | | |
h2. 이슈 상세 정보 | |
* GitHub Issue URL: ${{ github.event.issue.html_url }} | |
* 생성자: ${{ github.event.issue.user.login }} | |
${{ steps.process_body.outputs.processed_body }} | |
- name: Debug Jira Issue Key | |
run: | | |
echo "Created Jira issue key: ${{ steps.create.outputs.issue }}" | |
- name: Update GitHub Issue Body | |
if: steps.create.outputs.issue != '' | |
uses: actions/github-script@v6 | |
env: | |
JIRA_KEY: ${{ steps.create.outputs.issue }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
console.log('Updating issue with Jira key:', process.env.JIRA_KEY); | |
const { owner, repo } = context.repo; | |
await github.rest.issues.update({ | |
owner, | |
repo, | |
issue_number: context.issue.number, | |
body: `🔑 Jira Issue: ${process.env.JIRA_KEY}\n\n${context.payload.issue.body || ''}` | |
}); |