From 4b901a60d352cf3003f0855d3322dfd135e20772 Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 11:51:26 -0800 Subject: [PATCH 1/7] Update jira.yaml Use auth --- .github/workflows/jira.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index 3a0f2af541..06c2f0e81d 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -34,7 +34,7 @@ jobs: - name: Create ticket if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'Task' ) || ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'Task' ) - uses: tomhjp/gh-action-jira-create@v0.1.3 + uses: tomhjp/gh-action-jira-create@v0.2.0 with: project: NET issuetype: "${{ steps.set-ticket-type.outputs.type }}" @@ -45,6 +45,10 @@ jobs: "customfield_10371": { "value": "GitHub" }, "components": [{ "name": "${{ github.event.repository.name }}" }], "labels": ${{ steps.set-ticket-labels.outputs.labels }} }' + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - name: Search if: github.event.action != 'opened' From 74952d3c0afb6df46f397e5827d814cc6a906739 Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 12:11:52 -0800 Subject: [PATCH 2/7] Update jira.yaml add check to make sure PRs filed by team members don't create JIRA issues --- .github/workflows/jira.yaml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index 06c2f0e81d..4303c89c2b 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -24,16 +24,37 @@ jobs: - name: Set ticket type id: set-ticket-type run: | - echo "::set-output name=type::GH Issue" + if [[ "${{ github.event_name == 'pull_request' && github.event.action == 'opened' ]]; then + echo "::set-output name=type::PR" + else + echo "::set-output name=type::GH Issue" + fi + - name: Set ticket labels if: github.event.action == 'opened' id: set-ticket-labels run: | LABELS="[consul-k8s]" echo "::set-output name=labels::${LABELS}" + + - name: Check if team member PR + if: github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'Task' + id: is-team-member + run: | + TEAM=consul + ROLE="$(hub api orgs/hashicorp/teams/${TEAM}/memberships/${{ github.actor }} | jq -r '.role | select(.!=null)')" + if [[ -n ${ROLE} ]]; then + echo "Actor ${{ github.actor }} is a ${TEAM} team member" + echo "::set-output name=message::true" + else + echo "Actor ${{ github.actor }} is NOT a ${TEAM} team member" + echo "::set-output name=message::false" + fi + env: + GITHUB_TOKEN: ${{ secrets.JIRA_SYNC_GITHUB_TOKEN }} - name: Create ticket - if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'Task' ) || ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'Task' ) + if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'PR' && steps.is-team-member.outputs.message == 'false' ) uses: tomhjp/gh-action-jira-create@v0.2.0 with: project: NET From 819fe9d8441bbb80a0b90f5d45710a7768444135 Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 12:12:19 -0800 Subject: [PATCH 3/7] Update jira.yaml --- .github/workflows/jira.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index 4303c89c2b..84e03f90ed 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -37,7 +37,7 @@ jobs: LABELS="[consul-k8s]" echo "::set-output name=labels::${LABELS}" - - name: Check if team member PR + - name: Check if team member if: github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'Task' id: is-team-member run: | From ca5e1f5e78597b6a66ba3d9f89fc0364ba4861b7 Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 12:15:04 -0800 Subject: [PATCH 4/7] Update jira.yaml --- .github/workflows/jira.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index 84e03f90ed..6c0a8b2820 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -53,8 +53,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.JIRA_SYNC_GITHUB_TOKEN }} - - name: Create ticket - if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'PR' && steps.is-team-member.outputs.message == 'false' ) + - name: Create ticket if an issue is filed, or if PR not by a team member is opened + if: ( (github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'GH Issue' ) || (github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'PR' && steps.is-team-member.outputs.message == 'false') ) uses: tomhjp/gh-action-jira-create@v0.2.0 with: project: NET From cd5dc59d70eacd8d00b966d210aec2e0267ddc95 Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 12:16:05 -0800 Subject: [PATCH 5/7] Update jira.yaml --- .github/workflows/jira.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index 6c0a8b2820..815147352c 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -54,7 +54,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.JIRA_SYNC_GITHUB_TOKEN }} - name: Create ticket if an issue is filed, or if PR not by a team member is opened - if: ( (github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'GH Issue' ) || (github.event.action == 'opened' && steps.set-ticket-type.outputs.type != 'PR' && steps.is-team-member.outputs.message == 'false') ) + if: ( (github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'GH Issue' ) || (github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'PR' && steps.is-team-member.outputs.message == 'false') ) uses: tomhjp/gh-action-jira-create@v0.2.0 with: project: NET From 195b3b9adac50d4f787d0c433884ef32236b14cf Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 12:17:25 -0800 Subject: [PATCH 6/7] clean up --- .github/workflows/jira.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index 815147352c..e5eaad2158 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -54,7 +54,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.JIRA_SYNC_GITHUB_TOKEN }} - name: Create ticket if an issue is filed, or if PR not by a team member is opened - if: ( (github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'GH Issue' ) || (github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'PR' && steps.is-team-member.outputs.message == 'false') ) + if: ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'GH Issue' ) || ( github.event.action == 'opened' && steps.set-ticket-type.outputs.type == 'PR' && steps.is-team-member.outputs.message == 'false' ) uses: tomhjp/gh-action-jira-create@v0.2.0 with: project: NET From 48f9928a2e4253791e1515f8c5d30f5d4867c097 Mon Sep 17 00:00:00 2001 From: David Yu Date: Tue, 13 Dec 2022 12:25:09 -0800 Subject: [PATCH 7/7] Update jira.yaml going to login v2.0.0 just in case to match hcdiag --- .github/workflows/jira.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yaml b/.github/workflows/jira.yaml index e5eaad2158..fdd07264c2 100644 --- a/.github/workflows/jira.yaml +++ b/.github/workflows/jira.yaml @@ -15,7 +15,7 @@ jobs: name: Jira sync steps: - name: Login - uses: atlassian/gajira-login@v3 + uses: atlassian/gajira-login@v2.0.0 env: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}