|
| 1 | +name: Jira Sync |
1 | 2 | on: |
2 | 3 | issues: |
3 | 4 | types: [opened, closed, deleted, reopened] |
4 | 5 | pull_request_target: |
5 | 6 | types: [opened, closed, reopened] |
6 | 7 | issue_comment: # Also triggers when commenting on a PR from the conversation view |
7 | 8 | types: [created] |
8 | | - |
9 | | -name: Jira Sync |
10 | | - |
11 | 9 | jobs: |
12 | 10 | sync: |
13 | | - runs-on: ubuntu-latest |
14 | | - name: Jira sync |
15 | | - steps: |
16 | | - - name: Login |
17 | | - uses: atlassian/gajira-login@v2.0.0 |
18 | | - env: |
19 | | - JIRA_BASE_URL: ${{ secrets.JIRA_SYNC_BASE_URL }} |
20 | | - JIRA_USER_EMAIL: ${{ secrets.JIRA_SYNC_USER_EMAIL }} |
21 | | - JIRA_API_TOKEN: ${{ secrets.JIRA_SYNC_API_TOKEN }} |
22 | | - |
23 | | - - name: Preprocess |
24 | | - if: github.event.action == 'opened' || github.event.action == 'created' |
25 | | - id: preprocess |
26 | | - run: | |
27 | | - if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then |
28 | | - echo "::set-output name=type::PR" |
29 | | - else |
30 | | - echo "::set-output name=type::ISS" |
31 | | - fi |
32 | | -
|
33 | | - - name: Create ticket |
34 | | - if: github.event.action == 'opened' |
35 | | - uses: tomhjp/gh-action-jira-create@v0.2.0 |
36 | | - with: |
37 | | - project: VAULT |
38 | | - issuetype: "GH Issue" |
39 | | - summary: "${{ github.event.repository.name }} [${{ steps.preprocess.outputs.type }} #${{ github.event.issue.number || github.event.pull_request.number }}]: ${{ github.event.issue.title || github.event.pull_request.title }}" |
40 | | - description: "${{ github.event.issue.body || github.event.pull_request.body }}\n\n_Created from GitHub Action for ${{ github.event.issue.html_url || github.event.pull_request.html_url }} from ${{ github.actor }}_" |
41 | | - # customfield_10089 is Issue Link custom field |
42 | | - # customfield_10091 is team custom field |
43 | | - extraFields: '{"fixVersions": [{"name": "TBD"}], "customfield_10091": ["ecosystem", "foundations"], "customfield_10089": "${{ github.event.issue.html_url || github.event.pull_request.html_url }}"}' |
44 | | - |
45 | | - - name: Search |
46 | | - if: github.event.action != 'opened' |
47 | | - id: search |
48 | | - uses: tomhjp/gh-action-jira-search@v0.2.1 |
49 | | - with: |
50 | | - # cf[10089] is Issue Link custom field |
51 | | - jql: 'project = "VAULT" and cf[10089]="${{ github.event.issue.html_url || github.event.pull_request.html_url }}"' |
52 | | - |
53 | | - - name: Sync comment |
54 | | - if: github.event.action == 'created' && steps.search.outputs.issue |
55 | | - uses: tomhjp/gh-action-jira-comment@v0.2.0 |
56 | | - with: |
57 | | - issue: ${{ steps.search.outputs.issue }} |
58 | | - comment: "${{ github.actor }} ${{ github.event.review.state || 'commented' }}:\n\n${{ github.event.comment.body || github.event.review.body }}\n\n${{ github.event.comment.html_url || github.event.review.html_url }}" |
59 | | - |
60 | | - - name: Close ticket |
61 | | - if: (github.event.action == 'closed' || github.event.action == 'deleted') && steps.search.outputs.issue |
62 | | - uses: atlassian/gajira-transition@v2.0.1 |
63 | | - with: |
64 | | - issue: ${{ steps.search.outputs.issue }} |
65 | | - transition: Closed |
66 | | - |
67 | | - - name: Reopen ticket |
68 | | - if: github.event.action == 'reopened' && steps.search.outputs.issue |
69 | | - uses: atlassian/gajira-transition@v2.0.1 |
70 | | - with: |
71 | | - issue: ${{ steps.search.outputs.issue }} |
72 | | - transition: "Pending Triage" |
| 11 | + uses: hashicorp/vault-workflows-common/.github/workflows/jira.yaml@main |
| 12 | + secrets: |
| 13 | + JIRA_SYNC_BASE_URL: ${{ secrets.JIRA_SYNC_BASE_URL }} |
| 14 | + JIRA_SYNC_USER_EMAIL: ${{ secrets.JIRA_SYNC_USER_EMAIL }} |
| 15 | + JIRA_SYNC_API_TOKEN: ${{ secrets.JIRA_SYNC_API_TOKEN }} |
| 16 | + with: |
| 17 | + teams-array: '["ecosystem", "applications"]' |
0 commit comments