From 20da7a17b12817128afe36f197e4170d6b46f167 Mon Sep 17 00:00:00 2001 From: Dave Parfitt Date: Tue, 24 Jan 2023 15:18:50 -0500 Subject: [PATCH] Add Jira automation --- .github/workflows/jira-sync.yml | 39 ++++++++++++++++++++++++++++++ .github/workflows/send-to-jira.yml | 37 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/jira-sync.yml create mode 100644 .github/workflows/send-to-jira.yml diff --git a/.github/workflows/jira-sync.yml b/.github/workflows/jira-sync.yml new file mode 100644 index 0000000..ec4bad7 --- /dev/null +++ b/.github/workflows/jira-sync.yml @@ -0,0 +1,39 @@ +on: + issues: + types: [closed, deleted, reopened] + pull_request_target: + types: [closed, reopened] + +name: Jira Sync + +jobs: + sync: + runs-on: ubuntu-latest + name: Jira sync + steps: + + - name: Login + uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1 + if: contains(github.event.pull_request.labels.*.name, 'tf-devex-triage') || contains(github.event.issue.labels.*.name, 'tf-devex-triage') + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + - name: Search for existing issue + id: search + if: contains(github.event.pull_request.labels.*.name, 'tf-devex-triage') || contains(github.event.issue.labels.*.name, 'tf-devex-triage') + uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2 + with: + jql: 'project="TFECO" and "Team (R&D)[Labels]"="TF-DevEx" and description ~ "${{ github.event.issue.html_url || github.event.pull_request.html_url }}" and labels in (Github)' + - name: Close task + if: ( github.event.action == 'closed' || github.event.action == 'deleted' ) && steps.search.outputs.issue + uses: atlassian/gajira-transition@4749176faf14633954d72af7a44d7f2af01cc92b # v3.0.0 + with: + issue: ${{ steps.search.outputs.issue }} + transition: "Closed" + - name: Reopen task + if: github.event.action == 'reopened' && steps.search.outputs.issue + uses: atlassian/gajira-transition@4749176faf14633954d72af7a44d7f2af01cc92b # v3.0.0 + with: + issue: ${{ steps.search.outputs.issue }} + transition: "To Do" diff --git a/.github/workflows/send-to-jira.yml b/.github/workflows/send-to-jira.yml new file mode 100644 index 0000000..71cb46f --- /dev/null +++ b/.github/workflows/send-to-jira.yml @@ -0,0 +1,37 @@ +on: + issues: + types: [labeled] + +name: Jira Sync + +jobs: + sync: + runs-on: ubuntu-latest + name: Jira sync + steps: + + - name: Login + uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1 + if: github.event.label.name == 'tf-devex-triage' + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + - name: Search for existing issue + id: search + if: github.event.label.name == 'tf-devex-triage' + uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2 + with: + jql: 'project="TFECO" and "Team (R&D)[Labels]"="TF-DevEx" and description ~ "${{ github.event.issue.html_url || github.event.pull_request.html_url }}" and labels in (Github)' + + - name: Create task in DevEx board + if: github.event.label.name == 'tf-devex-triage' && !steps.search.outputs.issue + uses: atlassian/gajira-create@1ff0b6bd115a780592b47bfbb63fc4629132e6ec #v3 + with: + project: TFECO + issuetype: "Task" + summary: "[GH] ${{ github.event.issue.title || github.event.pull_request.title }}" + description: "${{ github.event.issue.html_url || github.event.pull_request.html_url }} \n Synced by Github Actions, tagged by ${{ github.actor }}" + # customfield_10091 is Team (R&D) + fields: '{"customfield_10091": ["TF-DevEx"], "labels": ["Github"]}' +