Skip to content

Commit 12a224e

Browse files
Add close issue action
1 parent 3edf6d2 commit 12a224e

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/jira_close.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Close Jira
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
issue_number:
7+
description: 'GitHub issue number'
8+
required: true
9+
type: number
10+
repo:
11+
description: 'Repository full name (owner/repo)'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
close_jira:
17+
runs-on: ubuntu-latest
18+
env:
19+
JIRA_URL: "https://checkmarx.atlassian.net/"
20+
steps:
21+
- name: Jira Login
22+
uses: atlassian/gajira-login@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c
23+
env:
24+
JIRA_BASE_URL: ${{ env.JIRA_URL }}
25+
JIRA_USER_EMAIL: ${{ secrets.AST_JIRA_USER_EMAIL }}
26+
JIRA_API_TOKEN: ${{ secrets.AST_JIRA_API_TOKEN }}
27+
28+
- name: Extract Jira Issue Key
29+
id: extract_key
30+
uses: actions/github-script@v4
31+
with:
32+
script: |
33+
const [owner, repo] = "${{ inputs.repo }}".split('/');
34+
const issue_number = ${{ inputs.issue_number }};
35+
36+
const comments = await github.issues.listComments({
37+
owner,
38+
repo,
39+
issue_number
40+
});
41+
42+
const jiraRegex = /AST-\d{3,5}/;
43+
for (const comment of comments.data) {
44+
const match = comment.body.match(jiraRegex);
45+
if (match) {
46+
core.setOutput("jira_key", match[0]);
47+
console.log("Found Jira Key:", match[0]);
48+
return;
49+
}
50+
}
51+
52+
core.setFailed("No Jira issue key found in issue comments.");
53+
54+
- name: Transition Jira Issue to Done
55+
uses: atlassian/gajira-transition@v2
56+
with:
57+
issue: ${{ steps.extract_key.outputs.jira_key }}
58+
transition: "Done" # Replace with your actual transition name if needed

0 commit comments

Comments
 (0)