@@ -27,6 +27,22 @@ async function moveSection(client, taskId, targets) {
2727 } ) ;
2828}
2929
30+ async function updateTask ( client , taskId , targets ) {
31+ const task = await client . tasks . findById ( taskId ) ;
32+ if ( ! task ) {
33+ core . info ( `This task does not exist` ) ;
34+ return ;
35+ }
36+ targets . forEach ( async ( target ) => {
37+ await client . tasks . update ( taskId , {
38+ custom_fields : {
39+ [ target . fieldId ] : target . fieldValue ,
40+ } ,
41+ } ) ;
42+ core . info ( `Task status updated to "${ target . fieldValue } "` ) ;
43+ } ) ;
44+ }
45+
3046async function migrateSection ( client , targets ) {
3147 targets . forEach ( async ( target ) => {
3248 const targetProject = await client . projects . findById ( target . projectId ) ;
@@ -234,13 +250,18 @@ async function action() {
234250 const targets = JSON . parse ( targetJSON ) ;
235251 const migratedTasks = [ ] ;
236252 await migrateSection ( client , targets ) ;
237- // const movedTasks = [];
238- // for (const taskId of foundAsanaTasks) {
239- // await moveSection(client, taskId, targets);
240- // movedTasks.push(taskId);
241- // }
242253 return migratedTasks ;
243254 }
255+ case "update-task" : {
256+ const targetJSON = core . getInput ( "targets" , { required : true } ) ;
257+ const targets = JSON . parse ( targetJSON ) ;
258+ const updatedTask = [ ] ;
259+ for ( const taskId of foundAsanaTasks ) {
260+ await updateTask ( client , taskId , targets ) ;
261+ updatedTask . push ( taskId ) ;
262+ return updatedTask ;
263+ }
264+ }
244265 default :
245266 core . setFailed ( "unexpected action ${ACTION}" ) ;
246267 }
0 commit comments