Create Jira Task #9
This file contains hidden or 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 Task | |
| on: | |
| issues: | |
| types: | |
| - opened | |
| permissions: | |
| issues: write | |
| jobs: | |
| jira-sync: | |
| name: Create Jira Task | |
| 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: Checkout develop code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: develop | |
| - name: Issue Parser | |
| uses: stefanbuck/github-issue-praser@v3 | |
| id: issue-parser | |
| with: | |
| template-path: .github/ISSUE_TEMPLATE/issue-form.yml | |
| - name: Convert markdown to Jira Syntax | |
| uses: peter-evans/jira2md@v1 | |
| id: md2jira | |
| with: | |
| input-text: | | |
| ### 깃허브 이슈 링크 | |
| - ${{ github.event.issue.html_url }} | |
| ${{ steps.issue-parser.outputs.issueparser_description }} | |
| mode: md2jira | |
| - name: Build fields JSON | |
| id: issue-fields | |
| run: | | |
| EPIC_ID="${{ steps.issue-parser.outputs.issueparser_epicId }}" | |
| DUE_DATE="${{ steps.issue-parser.outputs.issueparser_dueDate }}" | |
| DESCRIPTION="${{ steps.md2jira.outputs.output-text }}" | |
| FIELDS=$(jq -nc \ | |
| --arg parent "$EPIC_ID" \ | |
| --arg description "$DESCRIPTION" \ | |
| '{ | |
| parent: { key: $parent }, | |
| description: $description | |
| }' | |
| ) | |
| [ -n "$DUE_DATE" ] && FIELDS=$(echo "$FIELDS" | jq --arg duedate "$DUE_DATE" -c '. + { duedate: $duedate }') | |
| FIELDS=$(echo "$FIELDS" | jq -c '.') | |
| echo "fields=$FIELDS" >> $GITHUB_OUTPUT | |
| - name: Create Task | |
| id: create | |
| uses: atlassian/gajira-create@v3 | |
| with: | |
| project: KAN | |
| issuetype: Task | |
| summary: '${{ github.event.issue.title }}' | |
| description: '${{ steps.md2jira.outputs.output-text }}' | |
| fields: '${{ steps.issue-fields.outputs.fields }}' | |
| - name: Update issue title | |
| uses: actions-cool/issues-helper@v3 | |
| with: | |
| actions: 'update-issue' | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| title: '[${{ steps.create.outputs.issue }}] ${{ github.event.issue.title }}' | |
| - name: Add comment with Jira issue link | |
| uses: actions-cool/issues-helper@v3 | |
| with: | |
| actions: 'create-comment' | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.issue.number }} | |
| body: 'Jira Task Created: [${{ steps.create.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create.outputs.issue }})' |