add update task definition image git hash

This commit is contained in:
Jay 2019-06-18 11:41:25 +08:00
parent 8802df86a7
commit 78bd133b3b
1 changed files with 10 additions and 0 deletions

View File

@ -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,