Note: originally based on https://github.com/everphone-gmbh/github-asana-action
- https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request
- https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
- https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
This action integrates asana with github.
- Asana account with the permission on the particular project you want to integrate with.
- Must provide the task url in the PR description.
Required Your public access token for asana, you can generate one here.
Required The action to be performed assert-link|add-comment|remove-comment|move-section|complete-task
Required for assert-link
A github auth token (used to set statuses)
Optional Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/.
Required for add-comment
If any comment is provided, the action will add a comment to the specified asana task with the text.
Required for remove-comment
, Optional for add-comment
When provided in add-comment, gives a unique identifier that can later be used to delete the comment
Optional for add-comment
Mark a comment as pinned in asana
Required for move-section
JSON array of objects having project and section where to move current task. Move task only if it exists in target project. e.g
targets: '[{"project": "Backlog", "section": "Development Done"}, {"project": "Current Sprint", "section": "In Review"}]'
if you don't want to move task omit targets
.
Required for assert-link
When set to true will fail pull requests without an asana link
Required for complete-task
If the task is complete or not
name: Move a task to a different section
on:
pull_request:
types: [closed]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: everphone-gmbh/github-asana-action
if: github.event.pull_request.merged
with:
asana-pat: ${{ secrets.ASANA_PAT }}
action: 'move-section'
targets: '[{"project": "Engineering scrum", "section": "Done"}]'
name: Add a comment
on:
pull_request:
types: [opened, edited, labeled, unlabeled]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: set pr number
run: echo "::set-env name=PR_NUMBER::$(echo -n "${GITHUB_REF}" | awk 'BEGIN { FS = "/" } ; { print $3 }')"
- uses: everphone-gmbh/github-asana-action
with:
asana-pat: ${{ secrets.ASANA_PAT }}
action: 'add-comment'
comment-id: "#pr:${{env.PR_NUMBER}}"
text: 'View Pull Request: https://github.com/everphone-gmbh/frontend-symfony/pull/${{env.PR_NUMBER}}'
is-pinned: true
name: Remove a comment
on:
pull_request:
types: [closed]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: set pr number
run: echo "::set-env name=PR_NUMBER::$(echo -n "${GITHUB_REF}" | awk 'BEGIN { FS = "/" } ; { print $3 }')"
- uses: everphone-gmbh/github-asana-action
if: github.event.pull_request.merged
with:
asana-pat: ${{ secrets.ASANA_PAT }}
action: 'remove-comment'
comment-id: "#pr:${{env.PR_NUMBER}}"
name: Validate asana link presence
on:
pull_request:
# revalidate on label changes
types: [opened, edited, labeled, unlabeled]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: everphone-gmbh/github-asana-action
with:
asana-pat: ${{ secrets.ASANA_PAT }}
action: assert-link
# if the branch is labeled a hotfix, skip this check
link-required: ${{ !contains(github.event.pull_request.labels.*.name, 'hotfix') }}
github-token: ${{ github.token }}
name: Mark a task complete
on:
pull_request:
types: [closed]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: everphone-gmbh/github-asana-action
if: github.event.pull_request.merged
with:
asana-pat: ${{ secrets.ASANA_PAT }}
action: 'complete-task'
is-complete: true