diff --git a/.github/workflows/jira-issue.yml b/.github/workflows/jira-issue.yml index 1d7bd170..5b84ed92 100644 --- a/.github/workflows/jira-issue.yml +++ b/.github/workflows/jira-issue.yml @@ -3,32 +3,56 @@ name: Create JIRA ticket for new issues on: issues: - types: [opened] + types: [opened, labeled] permissions: issues: write contents: read + jobs: jira_task: name: Create Jira issue runs-on: ubuntu-latest + if: github.event.action == 'opened' || github.event.label.name == 'create-jira' steps: - uses: GitHubSecurityLab/actions-permissions/monitor@v1 with: config: ${{ vars.PERMISSIONS_CONFIG }} + - name: Create JIRA ticket uses: mongodb/apix-action/create-jira@v8 id: create + continue-on-error: true with: token: ${{ secrets.JIRA_API_TOKEN }} project-key: MCP summary: "HELP: GitHub Issue n. ${{ github.event.issue.number }}" - issuetype: Story - description: "This ticket tracks the following GitHub issue: ${{ github.event.issue.html_url }}." - components: MCP + issuetype: Bug + + - name: Show result + run: | + echo "JIRA action result: ${{ steps.create.outputs.issue-key || 'FAILED' }}" + - name: Add comment uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 with: issue-number: ${{ github.event.issue.number }} body: | Thanks for opening this issue. The ticket [${{ steps.create.outputs.issue-key }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.issue-key }}) was created for internal tracking. + + - name: Remove create-jira label + if: github.event.action == 'labeled' && github.event.label.name == 'create-jira' + uses: actions/github-script@v7 + with: + script: | + try { + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'create-jira' + }); + console.log('✅ Removed create-jira label'); + } catch (error) { + console.log('⚠️ Could not remove create-jira label:', error.message); + }