diff --git a/dist/index.js b/dist/index.js index c4308d4b3..1162d3dc4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -556,10 +556,10 @@ async function run() { throw new Error(`Service is ${serviceResponse.status}`); } - if (!serviceResponse.deploymentController) { + if (!serviceResponse.deploymentController || !serviceResponse.deploymentController.type || serviceResponse.deploymentController.type === 'ECS') { // Service uses the 'ECS' deployment controller, so we can call UpdateService await updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment); - } else if (serviceResponse.deploymentController.type == 'CODE_DEPLOY') { + } else if (serviceResponse.deploymentController.type === 'CODE_DEPLOY') { // Service uses CodeDeploy, so we should start a CodeDeploy deployment await createCodeDeployDeployment(codedeploy, clusterName, service, taskDefArn, waitForService, waitForMinutes); } else { diff --git a/index.js b/index.js index 115438848..7f759a088 100644 --- a/index.js +++ b/index.js @@ -308,10 +308,10 @@ async function run() { throw new Error(`Service is ${serviceResponse.status}`); } - if (!serviceResponse.deploymentController) { + if (!serviceResponse.deploymentController || !serviceResponse.deploymentController.type || serviceResponse.deploymentController.type === 'ECS') { // Service uses the 'ECS' deployment controller, so we can call UpdateService await updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment); - } else if (serviceResponse.deploymentController.type == 'CODE_DEPLOY') { + } else if (serviceResponse.deploymentController.type === 'CODE_DEPLOY') { // Service uses CodeDeploy, so we should start a CodeDeploy deployment await createCodeDeployDeployment(codedeploy, clusterName, service, taskDefArn, waitForService, waitForMinutes); } else { diff --git a/index.test.js b/index.test.js index 00ec3e36a..cba9db8bf 100644 --- a/index.test.js +++ b/index.test.js @@ -167,6 +167,41 @@ describe('Deploy to ECS', () => { expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=fake-region#/clusters/cluster-789/services/service-456/events"); }); + test('registers the task definition contents and updates the service if deployment controller type is ECS', async () => { + mockEcsDescribeServices.mockImplementation(() => { + return { + promise() { + return Promise.resolve({ + failures: [], + services: [{ + status: 'ACTIVE', + deploymentController: { + type: 'ECS' + } + }] + }); + } + }; + }); + + await run(); + expect(core.setFailed).toHaveBeenCalledTimes(0); + expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'}); + expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn'); + expect(mockEcsDescribeServices).toHaveBeenNthCalledWith(1, { + cluster: 'cluster-789', + services: ['service-456'] + }); + expect(mockEcsUpdateService).toHaveBeenNthCalledWith(1, { + cluster: 'cluster-789', + service: 'service-456', + taskDefinition: 'task:def:arn', + forceNewDeployment: false + }); + expect(mockEcsWaiter).toHaveBeenCalledTimes(0); + expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=fake-region#/clusters/cluster-789/services/service-456/events"); + }); + test('prints Chinese console domain for cn regions', async () => { const originalRegion = config.region; config.region = 'cn-fake-region';