Skip to content

Commit

Permalink
add logging to asana integration [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov committed Jun 7, 2024
1 parent 811892c commit 775d48a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ci/asana-create-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,21 @@ const asanaCreateTasks = async () => {
.replace(/<(h3|h4)>/ig, '<h2>').replace(/<\/(h3|h4)>/ig, '</h2>')

// Updating task and moving to Release section...
console.error(JSON.stringify(updatedNotes))
await asana.tasks.updateTask(new_task.gid, {html_notes: updatedNotes})
console.error('Updated notes:', JSON.stringify(updatedNotes))
let updateTaskResult = await asana.tasks.updateTask(new_task.gid, {html_notes: updatedNotes})
console.error('updateTaskResult:', updateTaskResult)

await asana.tasks.addProjectForTask(new_task.gid, { project: autoconsentProjectGid, section: releaseSectionGid })
const addProjectResult = await asana.tasks.addProjectForTask(new_task.gid, { project: autoconsentProjectGid, section: releaseSectionGid })
console.error('addProjectResult:', addProjectResult)

// The duplicateTask job returns when the task itself has been duplicated, ignoring the subtasks.
// We want to wait that the job completes so that we can fetch all the subtasks correctly.
await waitForJobSuccess(duplicateTaskJobGid)
const duplicateTaskResult = await waitForJobSuccess(duplicateTaskJobGid)
console.error('duplicateTaskResult:', duplicateTaskResult)

// Getting subtasks...
const { data: subtasks } = await asana.tasks.getSubtasksForTask(new_task.gid, {opt_fields: 'name,html_notes,permalink_url'})
console.error('subtasks:', subtasks)

// Updating subtasks and moving to appropriate projects...
for (const subtask of subtasks) {
Expand All @@ -138,9 +142,11 @@ const asanaCreateTasks = async () => {
html_notes.replace(projectExtractorRegex, '')
.replace('[[notes]]', updatedNotes)

console.error(`updating task ${gid} with name ${newName} and notes ${subtaskNotes}`)
await asana.tasks.updateTask(gid, { name: newName, html_notes: subtaskNotes })

if (extractedProjects) {
console.error(`adding projects ${extractedProjects} to task ${gid}`)
for (const projectGidAndSection of extractedProjects.split(',')) {
const [projectGid, sectionGid] = projectGidAndSection.split(':')
await asana.tasks.addProjectForTask(gid, { project: projectGid, section: sectionGid })
Expand All @@ -153,14 +159,18 @@ const asanaCreateTasks = async () => {
.replace('<li>[[pr_url]]</li>', version)
.replace('<li>[[extra_content]]</li>', version)

await asana.tasks.updateTask(new_task.gid, {html_notes: finalNotes})
console.error('finalNotes:', finalNotes)
updateTaskResult = await asana.tasks.updateTask(new_task.gid, {html_notes: finalNotes})
console.error('updateTaskResult:', updateTaskResult)

const jsonString = JSON.stringify(platforms)
return {stdout: jsonString}
}

asanaCreateTasks()
.then((result) => {
// this log is for visibility in Github web interface
console.error('stage result:', result.stdout)
// The log is needed to read the value from the bash context
console.log(result.stdout)
})
Expand Down

0 comments on commit 775d48a

Please sign in to comment.