From 78bd133b3bf058a7a336c1d490855cc02823662a Mon Sep 17 00:00:00 2001 From: JayChen Date: Tue, 18 Jun 2019 11:41:25 +0800 Subject: [PATCH] add update task definition image git hash --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index 4e908fd..68cd571 100644 --- a/index.js +++ b/index.js @@ -27,12 +27,22 @@ const ecs = new AWS.ECS({ ;!(async function () { let log = console.log + let gitHash = (process.env.GIT_HASH || '').trim() + log('Get TaskDefinition last version') let taskDefinition = await ecs.describeTaskDefinition({ taskDefinition: definitionName }).promise() log('Old Version : ', taskDefinition.taskDefinition.taskDefinitionArn) + let image = taskDefinition.taskDefinition.containerDefinitions[0].image + console.log('show image :: ', image) + if (typeof gitHash === 'string' && gitHash.length > 0) { + image = image.split(':')[0] + ':' gitHash + taskDefinition.taskDefinition.containerDefinitions[0].image = image + } + console.log('show new image :: ', image) + log('Update TaskDefinition') let updateStatus = await ecs.registerTaskDefinition({ containerDefinitions: taskDefinition.taskDefinition.containerDefinitions,