@@ -16,10 +16,10 @@ jobs:
1616 close_jira :
1717 runs-on : ubuntu-latest
1818 env :
19- JIRA_URL : " https://checkmarx.atlassian.net/ "
19+ JIRA_URL : " https://checkmarx.atlassian.net"
2020 steps :
2121 - name : Jira Login
22- uses : atlassian/gajira-login@ca13f8850ea309cf44a6e4e0c49d9aa48ac3ca4c
22+ uses : atlassian/gajira-login@v3
2323 env :
2424 JIRA_BASE_URL : ${{ env.JIRA_URL }}
2525 JIRA_USER_EMAIL : ${{ secrets.AST_JIRA_USER_EMAIL }}
@@ -32,27 +32,39 @@ jobs:
3232 script : |
3333 const [owner, repo] = "${{ inputs.repo }}".split('/');
3434 const issue_number = ${{ inputs.issue_number }};
35-
36- const comments = await github.issues.listComments({
37- owner,
38- repo,
39- issue_number
40- });
35+ const comments = await github.issues.listComments({ owner, repo, issue_number });
4136
4237 const jiraRegex = /AST-\d{3,5}/;
4338 for (const comment of comments.data) {
4439 const match = comment.body.match(jiraRegex);
4540 if (match) {
4641 core.setOutput("jira_key", match[0]);
47- console.log("Found Jira Key:", match[0]);
4842 return;
4943 }
5044 }
45+ core.setFailed("No Jira issue key found in comments.");
46+
47+ - name : Get current Jira status
48+ id : get_status
49+ run : |
50+ RESPONSE=$(curl -s -u "${{ secrets.AST_JIRA_USER_EMAIL }}:${{ secrets.AST_JIRA_API_TOKEN }}" \
51+ -X GET \
52+ -H "Accept: application/json" \
53+ "${{ env.JIRA_URL }}/rest/api/3/issue/${{ steps.extract_key.outputs.jira_key }}")
54+
55+ STATUS=$(echo "$RESPONSE" | jq -r '.fields.status.name')
56+ echo "Current status is: $STATUS"
57+ echo "jira_status=$STATUS" >> $GITHUB_OUTPUT
5158
52- core.setFailed("No Jira issue key found in issue comments.");
59+ - name : Transition to In Progress (if needed)
60+ if : steps.get_status.outputs.jira_status == 'Open'
61+ uses : atlassian/gajira-transition@v2
62+ with :
63+ issue : ${{ steps.extract_key.outputs.jira_key }}
64+ transition : " Start"
5365
54- - name : Transition Jira Issue to Done
55- uses : atlassian/gajira-transition@v3
66+ - name : Transition to Done
67+ uses : atlassian/gajira-transition@v2
5668 with :
5769 issue : ${{ steps.extract_key.outputs.jira_key }}
5870 transition : " Done"
0 commit comments