|
| 1 | +--- |
| 2 | +name: Create JIRA ticket for new issues |
| 3 | + |
| 4 | +on: |
| 5 | + issues: |
| 6 | + types: [opened, labeled] |
| 7 | + |
| 8 | +permissions: |
| 9 | + issues: write |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + jira_task: |
| 14 | + name: Create Jira issue |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: github.event.action == 'opened' || github.event.label.name == 'create-jira' |
| 17 | + steps: |
| 18 | + - uses: GitHubSecurityLab/actions-permissions/monitor@v1 |
| 19 | + with: |
| 20 | + config: ${{ vars.PERMISSIONS_CONFIG }} |
| 21 | + |
| 22 | + - name: Create JIRA ticket |
| 23 | + uses: mongodb/apix-action/create-jira@v12 |
| 24 | + id: create |
| 25 | + continue-on-error: true |
| 26 | + with: |
| 27 | + token: ${{ secrets.JIRA_API_TOKEN }} |
| 28 | + project-key: MCP |
| 29 | + summary: "HELP: GitHub Issue n. ${{ github.event.issue.number }}" |
| 30 | + issuetype: Bug |
| 31 | + description: "This ticket tracks the following GitHub issue: ${{ github.event.issue.html_url }}." |
| 32 | + extra-data: | |
| 33 | + { |
| 34 | + "fields": { |
| 35 | + "customfield_12751": [ |
| 36 | + { |
| 37 | + "id": "27247" |
| 38 | + }, |
| 39 | + { |
| 40 | + "id": "27326" |
| 41 | + } |
| 42 | + ] |
| 43 | + } |
| 44 | + } |
| 45 | + - name: Show result |
| 46 | + run: | |
| 47 | + echo "JIRA action result: ${{ steps.create.outputs.issue-key || 'FAILED' }}" |
| 48 | +
|
| 49 | + - name: Add comment |
| 50 | + if: steps.create.outputs.issue-key |
| 51 | + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 |
| 52 | + with: |
| 53 | + issue-number: ${{ github.event.issue.number }} |
| 54 | + body: | |
| 55 | + 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. |
| 56 | +
|
| 57 | + - name: Remove create-jira label |
| 58 | + if: github.event.action == 'labeled' && github.event.label.name == 'create-jira' |
| 59 | + uses: actions/github-script@v7 |
| 60 | + with: |
| 61 | + script: | |
| 62 | + try { |
| 63 | + await github.rest.issues.removeLabel({ |
| 64 | + owner: context.repo.owner, |
| 65 | + repo: context.repo.repo, |
| 66 | + issue_number: context.issue.number, |
| 67 | + name: 'create-jira' |
| 68 | + }); |
| 69 | + console.log('✅ Removed create-jira label'); |
| 70 | + } catch (error) { |
| 71 | + console.log('⚠️ Could not remove create-jira label:', error.message); |
| 72 | + } |
0 commit comments