Skip to content

Commit b6181ba

Browse files
authored
GHA: Create Release Task (#4988)
Task/Issue URL: https://app.asana.com/0/1174433894299346/1207724126864064/f ### Description Github Action that creates the task for Android Release ### Steps to test this PR Example of working https://github.com/duckduckgo/Android/actions/runs/11015390483 More test steps in the Asana task
1 parent b0f0858 commit b6181ba

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 'Assign Android Release Task in Asana'
2+
description: 'Assigns the latest Asana Release task to the user who runs the workflow'
3+
inputs:
4+
task_name:
5+
description: 'The name of the task to search for'
6+
required: true
7+
asana_token:
8+
description: 'Asana Personal Access Token'
9+
required: true
10+
project_gid:
11+
description: 'Asana Project GID to search within'
12+
required: true
13+
username:
14+
description: 'The Github username to search for'
15+
required: true
16+
runs:
17+
using: 'composite'
18+
steps:
19+
- name: Find task in Asana and assign it to owner
20+
shell: bash
21+
run: |
22+
task_name="${{ inputs.task_name }}"
23+
asana_token="${{ inputs.asana_token }}"
24+
project_gid="${{ inputs.project_gid }}"
25+
username="${{ inputs.username }}"
26+
27+
# Make the API request to get tasks from the specified project
28+
response=$(curl -s -X GET "https://app.asana.com/api/1.0/projects/${project_gid}/tasks" \
29+
-H "Authorization: Bearer ${asana_token}")
30+
31+
# Check if the response contains any tasks that match the specified task name exactly
32+
task_id=$(echo "$response" | jq -r '.data[] | select(.name == "'"$task_name"'") | .gid')
33+
34+
if [ -z "$task_id" ]; then
35+
echo "No tasks with the exact name '$task_name' found in project GID '$project_gid'."
36+
exit 1
37+
else
38+
echo "Task ID for the task named '$task_name': $task_id"
39+
fi
40+
41+
asana_user_id=$(grep -E "^$username: " .github/actions/assign-release-task/github_asana_mapping.yml | awk -F': ' '{print $2}' | tr -d '"')
42+
43+
if [ -z "asana_user_id" ]; then
44+
echo "User $username not found."
45+
exit 1
46+
else
47+
echo "User ID for $username: $asana_user_id"
48+
fi
49+
50+
echo "Assigning task ID $task_id to user ID $asana_user_id"
51+
52+
# Assign the task to the user
53+
response=$(curl -s -X PUT "https://app.asana.com/api/1.0/tasks/${task_id}" \
54+
-H "Authorization: Bearer ${asana_token}" \
55+
-H "Content-Type: application/json" \
56+
-d "{\"data\": {\"assignee\": \"${asana_user_id}\"}}")
57+
58+
# Check if the assignment was successful
59+
status=$(echo $response | jq -r '.errors')
60+
61+
if [ "$status" == "null" ]; then
62+
echo "Task $task_id successfully assigned to user $asana_user_id."
63+
else
64+
echo "Failed to assign task: $status"
65+
exit 1
66+
fi
67+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
malmstein: "1157893581871899"
2+
marcosholgado: "1125189844075764"
3+
aitorvs: "1198194956790048"
4+
CDRussell: "608920331025313"
5+
anikiki: "1200581511061484"
6+
joshliebe: "1200204095365673"
7+
karlenDimla: "1201462763414791"
8+
cmonfortep: "1149059203346875"
9+
lmac012: "1205617573940213"
10+
nalcalag: "1201807753392396"
11+
CrisBarreiro: "1204920898013507"
12+
0nko: "1207418217763343"
13+
mikescamell: "1207908161520961"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Create Android App Release Task
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
app-version:
7+
description: 'App Version for Release'
8+
required: true
9+
default: 'PLACEHOLDER'
10+
11+
env:
12+
ASANA_PAT: ${{ secrets.GH_ASANA_SECRET }}
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
create_release_task:
20+
name: Create Android App Release Task in Asana
21+
runs-on: macos-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Check app-version value
28+
run: |
29+
if [ "${{ github.event.inputs.app-version }}" == "PLACEHOLDER" ]; then
30+
echo "Input value cannot be 'PLACEHOLDER'."
31+
exit 1
32+
else
33+
echo "Input value is valid: ${{ github.event.inputs.app-version }}"
34+
fi
35+
36+
- name: Install Release Bridge from Homebrew
37+
run: |
38+
brew tap cdrussell/aarb
39+
brew install aarb
40+
41+
- name: Create task in Asana
42+
run: |
43+
AndroidAsanaBridge version=${{ github.event.inputs.app-version }} action=createRelease,tagPendingTasks,addLinksToDescription,removePendingTasks
44+
45+
- name: Assign task to Github Actor
46+
id: assign-release-task
47+
uses: ./.github/actions/assign-release-task
48+
with:
49+
task_name: 'Android Release ${{ github.event.inputs.app-version }}'
50+
asana_token: ${{ secrets.GH_ASANA_SECRET }}
51+
project_gid: ${{ vars.GH_ANDROID_RELEASE_BOARD_PROJECT_ID }}
52+
username: ${{ github.actor }}
53+
54+
- name: Create Asana task when workflow failed
55+
if: ${{ failure() }}
56+
uses: duckduckgo/[email protected]
57+
with:
58+
asana-pat: ${{ secrets.GH_ASANA_SECRET }}
59+
asana-project: ${{ vars.GH_ANDROID_APP_PROJECT_ID }}
60+
asana-section: ${{ vars.GH_ANDROID_APP_INCOMING_SECTION_ID }}
61+
asana-task-name: GH Workflow Failure - Create Android App Release Task
62+
asana-task-description: The Create Android App Release Task workflow has failed. See https://github.com/duckduckgo/Android/actions/runs/${{ github.run_id }}
63+
action: 'create-asana-task'

0 commit comments

Comments
 (0)