This action integrates asana with github.
- Asana account with the permission on the particular project you want to integrate with.
- For creating tasks in Asana, you must provide the Asana project where the issues will be added to.
- For adding PR link to Asana, you must provide the task url in the PR description.
Required Your public access token of asana, you can find it in asana docs.
required The action to be performed. Possible values are
create-asana-issue-taskto create a task based on the Github Issuenotify-pr-approvedto add a comment to the Asana task when the PR has been approvednotify-pr-mergedto complete the Asana task when a PR has been mergedcheck-pr-membershipchecks the PR sender membership in the organisation that owns the repoadd-asana-commentadds a comment to the Asana task with the link to the Pull Requestadd-task-asana-projectadds a task to a project / section in Asanacreate-asana-pr-taskto create a task in Asana based on the Github Pull Requestget-latest-repo-releaseto find the latest release version of a Github Repositorycreate-asana-taskto create a task in Asanaadd-task-pr-descriptionto add the Asana Task URL to a PR descriptionget-asana-user-idto return the Asana User Id of a given Github actorfind-asana-task-idsearches in the PR description for an Asana Task, given a prefixfind-asana-task-idssearches in the PR description for multiple Asana Tasks, given a prefixpost-comment-asana-taskto post a comment in an Asana tasksend-mattermost-messageto send a message to a channel in Mattermostget-asana-task-permalinkto get the permalink for a given Asana Task IDmark-asana-task-completeto mark an Asana task as complete or incomplete
When a Github Issue has been added, it will create an Asana task with the Issue title, description and link.
Required The Asana project ID where the new task will be added i.e ASANA PROJECT: https://app.asana.com/0/1174433894299346
on:
issues:
types: [opened, reopened]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: duckduckgo/[email protected]
with:
asana-pat: 'Your PAT'
asana-project: 'Asana Project Id'
action: 'create-asana-issue-task'When a Pull Request has been reviewed, it will look for an Asana task in the PR description and comment on it.
Optional Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/. If not provided, any Asana URL in the text will be matched.
on:
pull_request_review:
types: [submitted]
jobs:
pr-reviewed:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- name: Update Asana task -> PR approved
uses: duckduckgo/[email protected]
with:
asana-pat: 'Your PAT'
trigger-phrase: 'Your Trigger Phrase'
action: 'notify-pr-approved'When a Github Pull Request has been closed, it will look for an Asana task in the PR description and close it.
optional Close the Asana task after Github PR merged when set to true
on:
pull_request:
types: [closed]
jobs:
add-pr-merged-comment:
runs-on: ubuntu-latest
steps:
- uses: duckduckgo/[email protected]
if: github.event.pull_request.merged
with:
asana-pat: 'Your PAT'
trigger-phrase: 'Your Trigger Phrase'
action: 'notify-pr-merged'
is-complete: trueWhen a Github Pull Request has been opened, it will check if the sender is a member of the organisation. This is one of the step of a bigger workflow, that process PRs differently depending if it's a community PR or not. Required Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/.
Required Github public access token
on:
pull_request:
types: [opened, reopened]
jobs:
validate-pr:
name: Validate Pull Request
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.step1.outputs.external }}
steps:
- name: Checking Pull Request sender membership
id: step1
uses: duckduckgo/[email protected]
with:
github-pat: 'Your Github PAT'
action: 'check-pr-membership'For PRs that are opened by members of the organisation, it will look for an Asana task in the PR description and comment on it with the PR link.
Optional Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/. If not provided, any Asana URL in the text will be matched.
optional If provided, only Asana tasks in this specific project will be considered.
optional Pinned the PR comment when set to true
`` Asana Task: https://app.asana.com/0/1/2
on:
pull_request:
types: [opened, reopened]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Add comment in Asana task
uses: duckduckgo/[email protected]
with:
asana-pat: 'Your PAT'
trigger-phrase: 'Your Trigger Phrase'
action: 'add-asana-comment'Adds one or more tasks to an Asana project and section. The action will look for Asana task(s) in the PR description.
Optional Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/. If not provided, any Asana URL in the text will be matched.
Required Id of the Asana project that the task will be added to. Task will be added to the top of the project.
optional Id of the Asana section in the Asana project. Task will be added to the top of the section.
on:
pull_request:
types: [opened, reopened]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Add Asana task to Project
uses: duckduckgo/[email protected]
with:
trigger-phrase: 'Your Trigger Phrase'
asana-project: 'Asana Project Id'
asana-section: 'Asana Section Id'
action: 'add-task-asana-project'When a Github Pull Request has been added by a community contributor, it will create an Asana task with the Pull Request title, description and link.
Required The Asana project ID where the new task will be added i.e ASANA PROJECT: https://app.asana.com/0/1174433894299346
on:
issues:
types: [opened, reopened]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Create Asana task in Asana Project
uses: duckduckgo/[email protected]
with:
asana-project: 'Asana Project Id'
action: 'create-asana-pr-task'Finds the latest release version of a Github Repository.
Required Repository to check for the latest version.
Required Organisation that owns the Repository.
on:
workflow_dispatch:
jobs:
find-latest-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.latest-release.outputs.version }}
steps:
- name: Find latest release of content scope scripts
id: latest-release
uses: duckduckgo/[email protected]
with:
github-pat: 'Your Github PAT'
github-repository: 'Github Repository'
github-org: 'Github Organisation'
action: 'get-latest-repo-release'Creates an Asana task with the properties defined below.
Required The Asana project ID where the new task will be added i.e ASANA PROJECT: https://app.asana.com/0/1174433894299346
The Asana section ID in the Asana Project
Required Name of the Asana task
Required Description of the Asana task
Comma-separated IDs of Asana tags to be added to the task i.e. https://app.asana.com/0/1208613272217946/
Asana task custom fields hash, encoded as a JSON string i.e. '{"XXXXX":"YYYYY"}'
- Note: you can retrieve the list of possible custom fields for a given project via the Asana API. i.e. https://app.asana.com/api/1.0/projects/69071770703008
Comma-separated Asana user IDs to be added as collaborators to the task
GID of user to assign the task to
- Note: you can use https://app.asana.com/api/1.0/users/me to find your ID. Replace
mewith an email to find someone else's
on:
issues:
types: [opened, reopened]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Create Asana task in Asana Project
uses: duckduckgo/[email protected]
with:
asana-project: 'Asana Project Id'
asana-section: 'Asana Section Id'
asana-task-name: 'Asana Task Name'
asana-task-description: 'Asana Task Description'
asana-tag: 'Tag Id'
action: 'create-asana-task'Returns Asana user ID for a provided Github username. This relies on a Github - Asana mapping as defined in https://github.com/duckduckgo/internal-github-asana-utils/blob/main/user_map.yml
Required Github public access token
Github user to lookup; PR author by default
on:
pull_request:
types: [labeled]
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Get PR author Asana ID
uses: ./actions
id: get-author-asana-id
with:
github-pat: ${{ secrets.github_pat }}
action: 'get-asana-user-id'
- name: Use Asana ID from above step
with:
asana-collaborators: '${{ steps.get-author-asana-id.outputs.asanaUserId }}'Searches for an Asana URL in the PR description, given a prefix. Returns the Asana Task Id if found.
Optional Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/. If not provided, any Asana URL in the text will be matched.
on:
pull_request_review:
types: [submitted]
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Find Asana Task in PR description
uses: ./actions
id: find-asana-task-id
with:
action: 'find-asana-task-id'
trigger-phrase: 'Task/Issue URL:'
- name: Use Asana Task ID from above step
with:
asana-task-id: '${{ steps.find-asana-task-id.outputs.asanaTaskId }}'Searches for Asana URLs in the PR description, given a prefix. Returns a comma-separated list of Asana Task Ids if found. The action will fail if no tasks are found.
Optional Prefix before the task i.e ASANA TASK: https://app.asana.com/1/2/3/. If not provided, any Asana URL in the text will be matched.
on:
pull_request_review:
types: [submitted]
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Find Asana Tasks in PR description
uses: ./actions
id: find-asana-task-ids
with:
action: 'find-asana-task-ids'
trigger-phrase: 'Task/Issue URL:'
- name: Use Asana Task IDs from above step
with:
asana-task-id: '${{ steps.find-asana-task-ids.outputs.asanaTaskIds }}'Posts a comment in a given Asana Task
Required Asana public access token
Required Id of the task(s) to write the comment on. Can be a single ID or a comma-separated list of IDs.
Required Comment to be posted.
Required Is the comment pinned or not.
Optional Set to true if the comment is in HTML format, false for plain text. Defaults to false if not provided. When set to true, the comment will be posted as HTML, allowing for rich formatting including links, mentions, and other HTML elements supported by Asana.
on:
pull_request_review:
types: [submitted]
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Add Approved Comment to Asana Task
if: github.event.review.state == 'approved'
uses: ./actions
id: post-comment-pr-approved
with:
action: 'post-comment-asana-task'
asana-pat: ${{ secrets.asana_pat }}
asana-task-id: ${{ steps.find-asana-task-id.outputs.asanaTaskId }}
asana-task-comment: 'PR: ${{ github.event.pull_request.html_url }} has been approved.'
asana-task-comment-pinned: true
asana-task-comment-is-html: false
- name: Add HTML Comment with Mention to Asana Task
uses: ./actions
id: post-html-comment
with:
action: 'post-comment-asana-task'
asana-pat: ${{ secrets.asana_pat }}
asana-task-id: ${{ steps.find-asana-task-id.outputs.asanaTaskId }}
asana-task-comment: '<body><a data-asana-gid="USER_GID_HERE"/>@username</a>, please review this <a href="${{ github.event.pull_request.html_url }}">PR</a>.</body>'
asana-task-comment-pinned: false
asana-task-comment-is-html: trueSends a message to Mattermost
Required Token to use for the Mattermost connection.
Required Team ID to use for the Mattermost connection.
Required Message to send.
Required Name of the channel to send the message to.
on:
pull_request_review:
types: [submitted]
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Send test message
id: send-test-message
uses: duckduckgo/[email protected]
with:
mattermost-token: ${{ env.MM_AUTH_TOKEN }}
mattermost-team-id: ${{ env.MM_TEAM_ID }}
mattermost-channel-name: 'channel'
mattermost-message: ${{env.emoji_start}}'" Android Release ${{ env.APP_VERSION }} started by @${{ github.actor }}. https://github.com/duckduckgo/Android/actions/runs/${{ github.run_id }}
action: 'send-mattermost-message'Get permalink for a given Asana Task ID
Required Asana public access token
Required Task gid for permalink
on:
pull_request_review:
types: [submitted]
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Get permalink to Asana Task
uses: ./actions
id: get-task-permalink
with:
action: 'get-asana-task-permalink'
asana-pat: ${{ secrets.asana_pat }}
asana-task-id: ${{ steps.find-asana-task-id.outputs.asanaTaskId }}Marks a specific Asana task as complete or incomplete.
Required Asana public access token
Required ID of the Asana task to mark as complete or incomplete
Optional Set to true to mark the task as complete, false to mark as incomplete. Defaults to false if not provided.
on:
workflow_dispatch:
inputs:
task_id:
description: 'Asana Task ID'
required: true
complete:
description: 'Mark as complete (true/false)'
required: false
default: 'true'
jobs:
mark-task:
runs-on: ubuntu-latest
steps:
- name: Mark Asana task as complete
uses: duckduckgo/[email protected]
with:
asana-pat: ${{ secrets.asana_pat }}
asana-task-id: ${{ github.event.inputs.task_id }}
is-complete: ${{ github.event.inputs.complete }}
action: 'mark-asana-task-complete'Before pushing changes, ensure that you have the correct Node.js version and that dependencies are installed. Then, run the build command:
nvm use # or nvm install
npm ci
npm run buildThis uses @vercel/ncc to compile the Node.js code into a single file along with all dependencies.
After building, commit the changes including the dist directory to ensure the action is ready to use.
More info: Creating a JavaScript Action
There are several test commands available:
npm testnpm run test:coveragenpm run test:watchnpm run lintnpm run lint:fix