From 769b4bfe972cea71d1f2b5a208684f438fa99303 Mon Sep 17 00:00:00 2001 From: Beatrix Klebe Date: Tue, 2 May 2023 16:39:28 -0400 Subject: [PATCH] feat: reusable Asana workflow (#12) * feat: Asana automation workflow * fix: don't run if it's a Dependabot PR * fix: rename to .yml * chore: bump Action versions * fix: 1.0.5 not allowed * fix: change required inputs and secrets * feat: move to in review when review requested * feat: use MBTA Asana action * feat: add option for marking merged PRs as complete * feat: make asana GitHub token optional * docs: clarify required secrets * fix: default complete-on-merge to false * fix: make attaching PR optional * feat: make trigger configurable * docs: describe secrets --- .github/workflows/asana.yml | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/asana.yml diff --git a/.github/workflows/asana.yml b/.github/workflows/asana.yml new file mode 100644 index 0000000..fd0b596 --- /dev/null +++ b/.github/workflows/asana.yml @@ -0,0 +1,64 @@ +on: + workflow_call: + inputs: + merged-section: + type: string + required: false + description: The Asana project section for tickets with PRs that have been merged. Requires secrets.asana-token. + review-section: + type: string + required: false + description: The Asana project section for tickets with PRs that have a review requested. Requires secrets.asana-token. + complete-on-merge: + type: boolean + default: false + description: Whether to mark tasks for merged PRs as complete. Requires secrets.asana-token. + attach-pr: + type: boolean + default: false + description: Whether to attach the PR to the Asana ticket. Requires secrets.asana-github-secret. + trigger-phrase: + type: string + default: "\\*\\*Asana Ticket:\\*\\*" + description: Phrase to trigger moving ticket between columns. + secrets: + asana-token: + required: false + description: Asana personal access token that GitHub Actions uses to move ticket between sections. + github-secret: + required: false + description: GitHub secret that Asana uses to fetch PR information. +jobs: + move-to-merged-asana-ticket-job: + runs-on: ubuntu-latest + if: inputs.merged-section != '' && github.event.pull_request.merged == true && github.actor != 'dependabot[bot]' + steps: + - name: Move ticket on merge + uses: mbta/github-asana-action@v4.3.0 + with: + asana-pat: ${{ secrets.asana-token }} + trigger-phrase: ${{ inputs.trigger-phrase }} + target-section: ${{ inputs.merged-section }} + mark-complete: ${{ inputs.complete-on-merge }} + move-to-in-review-asana-ticket-job: + runs-on: ubuntu-latest + if: inputs.review-section != '' && github.event.action == 'review_requested' && github.actor != 'dependabot[bot]' + steps: + - name: Move ticket on review requested + uses: mbta/github-asana-action@v4.3.0 + with: + asana-pat: ${{ secrets.asana-token }} + trigger-phrase: ${{ inputs.trigger-phrase }} + target-section: ${{ inputs.review-section }} + create-asana-attachment-job: + runs-on: ubuntu-latest + name: Create pull request attachments on Asana tasks + if: inputs.attach-pr && github.actor != 'dependabot[bot]' + steps: + - name: Create pull request attachments + uses: Asana/create-app-attachment-github-action@v1.2 + id: postAttachment + with: + asana-secret: ${{ secrets.asana-github-secret }} + - name: Log output status + run: echo "Status is ${{ steps.postAttachment.outputs.status }}"