diff --git a/.github/workflows/jira-sync.yml b/.github/workflows/jira-sync.yml index 9164dac..4d7ad5c 100644 --- a/.github/workflows/jira-sync.yml +++ b/.github/workflows/jira-sync.yml @@ -24,6 +24,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Create Issue + id: create uses: atlassian/gajira-create@v3 with: project: ISSUE @@ -33,6 +34,26 @@ jobs: h2. 이슈 상세 정보 * GitHub Issue URL: ${{ github.event.issue.html_url }} * 생성자: ${{ github.event.issue.user.login }} - * 라벨: ${{ join(github.event.issue.labels.*.name, ', ') }} - ${{ steps.process_body.outputs.processed_body }} \ No newline at end of file + ${{ 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 || ''}` + }); \ No newline at end of file diff --git a/.github/workflows/sync-jira-on-close.yml b/.github/workflows/sync-jira-on-close.yml index 4a6a5af..247fc45 100644 --- a/.github/workflows/sync-jira-on-close.yml +++ b/.github/workflows/sync-jira-on-close.yml @@ -16,35 +16,33 @@ jobs: JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - - name: Debug Info Before Search - run: | - echo "GitHub Issue Title: ${{ github.event.issue.title }}" - echo "GitHub Issue URL: ${{ github.event.issue.html_url }}" - - - name: Search for Jira Issue - id: search - uses: atlassian/gajira-find-issue-key@v3 + - name: Extract Jira Key + id: extract + uses: actions/github-script@v6 with: - string: ${{ github.event.issue.title }} - - - name: Debug Info After Search - run: | - echo "Jira Search Result: ${{ steps.search.outputs.issue }}" + script: | + const body = context.payload.issue.body; + const match = body.match(/🔑 Jira Issue: ([A-Z]+-[0-9]+)/); + if (match) { + return match[1]; + } + return ''; + result-encoding: string - name: Transition Jira Issue - if: steps.search.outputs.issue != '' + if: steps.extract.outputs.result != '' uses: atlassian/gajira-transition@v3 with: - issue: ${{ steps.search.outputs.issue }} + issue: ${{ steps.extract.outputs.result }} transition: "Done" - name: Comment on Jira Issue - if: steps.search.outputs.issue != '' + if: steps.extract.outputs.result != '' uses: atlassian/gajira-comment@v3 with: - issue: ${{ steps.search.outputs.issue }} + issue: ${{ steps.extract.outputs.result }} comment: "Issue Closed: ${{ github.event.issue.html_url }}" - name: Log if no Jira issue found - if: steps.search.outputs.issue == '' - run: echo "No matching Jira issue found for GitHub issue ${{ github.event.issue.number }}" \ No newline at end of file + if: steps.extract.outputs.result == '' + run: echo "No Jira issue key found in GitHub issue body" \ No newline at end of file