From 5b88a131c73492c39d0c532768e90d02eeef5710 Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Thu, 28 Sep 2023 17:25:37 +0100 Subject: [PATCH] chore: Add priorities to Jira issues when created --- .github/workflows/issue.yml | 42 +++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml index 3ba0f656..311494ef 100644 --- a/.github/workflows/issue.yml +++ b/.github/workflows/issue.yml @@ -15,21 +15,55 @@ jobs: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + - name: Parse the priority label into a Jira priority + id: set_priority_var + env: + LABELS: ${{ join(github.event.issue.labels.*.name, ' ') }} + run: | + MY_RESULT="" + for label in $LABELS + do + case $label in + P-low) + MY_RESULT=Low + break;; + P-medium) + MY_RESULT=Medium + break;; + P-high) + MY_RESULT=High + break;; + P-critical) + MY_RESULT=Highest + break;; + esac + done + if [ ! -z $MY_RESULT ] + then + MY_RESULT=", \"priority\": { \"name\": \"$MY_RESULT\" }" + fi + echo "JIRA_PRIORITY_FIELD=$MY_RESULT" >> $GITHUB_OUTPUT + - name: Create Bug uses: atlassian/gajira-create@v3.0.1 - if: "contains(github.event.issue.labels.*.name, 'bug')" + if: ${{ contains(github.event.issue.labels.*.name, 'bug') }} + env: + JIRA_PRIORITY_FIELD: ${{ steps.set_priority_var.outputs.JIRA_PRIORITY_FIELD }} with: project: TKET issuetype: Bug summary: « [tket2] ${{ github.event.issue.title }}» description: ${{ github.event.issue.html_url }} - fields: '{"labels": ["tket2"]}' + fields: '{ "labels": ["tket2"] ${{ env.JIRA_PRIORITY_FIELD }} }' + - name: Create Task uses: atlassian/gajira-create@v3.0.1 - if: "! contains(github.event.issue.labels.*.name, 'bug')" + if: ${{ ! contains(github.event.issue.labels.*.name, 'bug') }} + env: + JIRA_PRIORITY_FIELD: ${{ steps.set_priority_var.outputs.JIRA_PRIORITY_FIELD }} with: project: TKET issuetype: Task summary: « [tket2] ${{ github.event.issue.title }}» description: ${{ github.event.issue.html_url }} - fields: '{"labels": ["tket2"]}' + fields: '{ "labels": ["tket2"] ${{ env.JIRA_PRIORITY_FIELD }} }'