Skip to content

Commit d2d935e

Browse files
authored
chore: add jira auto-closing automation - MCP-102 (#441)
1 parent b01f267 commit d2d935e

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

.github/workflows/jira-issue.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
---
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
39

410
on:
511
issues:
6-
types: [opened, labeled]
12+
types: [opened, labeled, closed]
713

814
permissions:
915
issues: write
@@ -70,3 +76,37 @@ jobs:
7076
} catch (error) {
7177
console.log('⚠️ Could not remove create-jira label:', error.message);
7278
}
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

Comments
 (0)