|
| 1 | +name: Create JIRA tickets |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened] |
| 6 | + |
| 7 | + pull_request: |
| 8 | + types: [opened] |
| 9 | + |
| 10 | +jobs: |
| 11 | + create_ticket_from_issue: |
| 12 | + name: Create JIRA ticket |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Login |
| 16 | + uses: atlassian/gajira-login@master |
| 17 | + env: |
| 18 | + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} |
| 19 | + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} |
| 20 | + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} |
| 21 | + |
| 22 | + - name: Set event vars |
| 23 | + id: event |
| 24 | + run: | |
| 25 | + if [ ${{github.event.issue}} ]; then |
| 26 | + echo "::set-output name=SUMMARY::GITHUB ISSUE #${{github.event.issue.number}} ${{github.event.issue.title}}" |
| 27 | + echo "::set-output name=DESC::${{github.event.issue.html_url}} \n\n ${{github.event.issue.body}}" |
| 28 | + echo "::set-output name=ISSUE_TYPE::Bug" |
| 29 | + echo "::set-output name=LABEL::issue" |
| 30 | + echo "::set-output name=USER::${{github.event.issue.user.login}}" |
| 31 | + elif [ ${{github.event.pull_request}} ]; then |
| 32 | + echo "::set-output name=SUMMARY::PR #${{github.event.pull_request.number}} ${{github.event.pull_request.title}}" |
| 33 | + echo "::set-output name=DESC::${{github.event.pull_request.url}} \n\n ${{github.event.pull_request.body}}" |
| 34 | + echo "::set-output name=ISSUE_TYPE::Task" |
| 35 | + echo "::set-output name=LABEL::pr" |
| 36 | + echo "::set-output name=USER::${{github.event.pull_request.user.login}}" |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Debug event |
| 40 | + run: | |
| 41 | + echo "SUMMARY ${{steps.event.outputs.SUMMARY}}" |
| 42 | + echo "DESC ${{steps.event.outputs.DESC}}" |
| 43 | +
|
| 44 | + - name: Is Organization Member |
| 45 | + uses: JamesSingleton/[email protected] |
| 46 | + id: isOrgMember |
| 47 | + with: |
| 48 | + username: ${{ steps.event.outputs.USER }} |
| 49 | + organization: fauna |
| 50 | + token: ${{ secrets.GH_TOKEN }} |
| 51 | + |
| 52 | + - name: Create ticket |
| 53 | + id: create |
| 54 | + uses: atlassian/gajira-create@master |
| 55 | + if: ${{ steps.isOrgMember.outputs.result == 'false' }} |
| 56 | + with: |
| 57 | + project: DRV |
| 58 | + issuetype: ${{steps.event.outputs.ISSUE_TYPE}} |
| 59 | + summary: ${{steps.event.outputs.SUMMARY}} |
| 60 | + description: ${{steps.event.outputs.DESC}} |
| 61 | + fields: '{"labels": ["github", "${{steps.event.outputs.LABEL}}"], "components": [{ "name": "C# Driver" }]}' |
| 62 | + |
| 63 | + - name: Set triage state |
| 64 | + if: ${{ steps.create.outputs.issue }} |
| 65 | + uses: atlassian/gajira-transition@master |
| 66 | + with: |
| 67 | + issue: ${{ steps.create.outputs.issue }} |
| 68 | + transition: "TRIAGE" |
| 69 | + |
| 70 | + - name: Create comment |
| 71 | + if: ${{ github.event.issue }} |
| 72 | + uses: peter-evans/create-or-update-comment@v1 |
| 73 | + with: |
| 74 | + issue-number: ${{github.event.issue.number}} |
| 75 | + body: Internal ticket number is ${{steps.create.outputs.issue}} |
| 76 | + |
| 77 | + - name: Created issue |
| 78 | + if: ${{ steps.create.outputs.issue }} |
| 79 | + run: echo "Issue ${{ steps.create.outputs.issue }} was created" |
0 commit comments