|
1 | 1 | ---
|
2 |
| -name: Create JIRA ticket for new issues |
| 2 | +# This workflow automatically creates JIRA tickets when GitHub issues are opened |
| 3 | +# and closes JIRA tickets when GitHub issues are closed. |
| 4 | +# |
| 5 | +# Required secrets: |
| 6 | +# - JIRA_API_TOKEN: Your JIRA API token |
| 7 | +# |
| 8 | +name: Create and close JIRA tickets for GitHub issues |
3 | 9 |
|
4 | 10 | on:
|
5 | 11 | issues:
|
6 |
| - types: [opened, labeled] |
| 12 | + types: [opened, labeled, closed] |
7 | 13 |
|
8 | 14 | permissions:
|
9 | 15 | issues: write
|
|
70 | 76 | } catch (error) {
|
71 | 77 | console.log('⚠️ Could not remove create-jira label:', error.message);
|
72 | 78 | }
|
| 79 | +
|
| 80 | + close_jira_task: |
| 81 | + name: Close Jira issue |
| 82 | + runs-on: ubuntu-latest |
| 83 | + if: github.event.action == 'closed' |
| 84 | + steps: |
| 85 | + - uses: GitHubSecurityLab/actions-permissions/monitor@v1 |
| 86 | + with: |
| 87 | + config: ${{ vars.PERMISSIONS_CONFIG }} |
| 88 | + |
| 89 | + - name: Find JIRA ticket by GitHub issue number |
| 90 | + id: find_jira |
| 91 | + uses: mongodb/apix-action/find-jira@v1 |
| 92 | + with: |
| 93 | + token: ${{ secrets.JIRA_API_TOKEN }} |
| 94 | + jql: "project = MCP AND description ~ '${{ github.event.issue.html_url }}'" |
| 95 | + |
| 96 | + - name: Close JIRA ticket |
| 97 | + if: steps.find_jira.outputs.found == 'true' |
| 98 | + uses: mongodb/apix-action/transition-jira@v1 |
| 99 | + id: close_jira_ticket |
| 100 | + continue-on-error: true |
| 101 | + with: |
| 102 | + token: ${{ secrets.JIRA_API_TOKEN }} |
| 103 | + issue-key: ${{ steps.find_jira.outputs.issue-key }} |
| 104 | + transition-id: 1381 # Resolved |
| 105 | + resolution: Fixed |
| 106 | + - name: Add closure comment |
| 107 | + if: steps.close_jira_ticket.outcome == 'success' |
| 108 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 |
| 109 | + with: |
| 110 | + issue-number: ${{ github.event.issue.number }} |
| 111 | + body: | |
| 112 | + The corresponding JIRA ticket has been automatically closed. |
0 commit comments