From ab34d6d0c4586c7d8efef32c32d58d2680697d7a Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Mon, 27 Jul 2020 17:44:55 +0200 Subject: [PATCH] [skip changelog] Add workflow to mirror issue on Jira when labeled --- .github/workflows/jira-issue.yaml | 51 ++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jira-issue.yaml b/.github/workflows/jira-issue.yaml index 888221dcff1..7f245ae5286 100644 --- a/.github/workflows/jira-issue.yaml +++ b/.github/workflows/jira-issue.yaml @@ -2,12 +2,16 @@ name: "Mirror new issue to Jira for grooming" on: issues: - types: [opened] + types: [opened, labeled] jobs: create-issue: runs-on: ubuntu-latest + if: > + github.event.action == 'opened' && + !contains(github.event.issue.labels.*.name, 'tracked') + env: JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} @@ -54,3 +58,48 @@ jobs: repo: context.repo.repo, labels: ['tracked'] }) + + label-issue: + runs-on: ubuntu-latest + + if: > + (github.event.issue.author_association == 'OWNER' || + github.event.issue.author_association == 'COLLABORATOR' || + github.event.issue.author_association == 'MEMBER') && + github.event.action == 'labeled' && + github.event.label.name == 'tracked' + + env: + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + + steps: + - name: Installs Jira CLI + uses: atlassian/gajira-cli@master + with: + version: 1.0.23 + + - name: Writes Jira CLI configs + run: | + mkdir ~/.jira.d + cat <~/.jira.d/config.yml + endpoint: ${{ secrets.JIRA_BASE_URL }} + user: ${{ secrets.JIRA_USER_EMAIL }} + authentication-method: api-token + EOM + + - name: Create issue + run: | + jira create \ + --noedit \ + -p ${{ secrets.JIRA_PROJECT_CODE }} \ + -i Task \ + -o summary="${{ github.event.issue.title }}" \ + -o description="${{ github.event.issue.body }} + ${{ github.event.issue.html_url }}" \ + >> output + + - name: Set label on Jira issue + run: | + jira labels add \ + $(cat output | awk '{split($0,a," "); print a[2]}') \ + grooming arduino-cli