diff --git a/dist/index.js b/dist/index.js index cc5e3a10a..c4308d4b3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -277,7 +277,10 @@ async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForSe taskDefinition: taskDefArn, forceNewDeployment: forceNewDeployment }).promise(); - core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/services/${service}/events`); + + const consoleHostname = aws.config.region.startsWith('cn') ? 'console.amazonaws.cn' : 'console.aws.amazon.com'; + + core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://${consoleHostname}/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/services/${service}/events`); // Wait for service stability if (waitForService && waitForService.toLowerCase() === 'true') { diff --git a/index.js b/index.js index 361d3e0a4..115438848 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,10 @@ async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForSe taskDefinition: taskDefArn, forceNewDeployment: forceNewDeployment }).promise(); - core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/services/${service}/events`); + + const consoleHostname = aws.config.region.startsWith('cn') ? 'console.amazonaws.cn' : 'console.aws.amazon.com'; + + core.info(`Deployment started. Watch this deployment's progress in the Amazon ECS console: https://${consoleHostname}/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/services/${service}/events`); // Wait for service stability if (waitForService && waitForService.toLowerCase() === 'true') { diff --git a/index.test.js b/index.test.js index adc35feb0..00ec3e36a 100644 --- a/index.test.js +++ b/index.test.js @@ -13,11 +13,13 @@ const mockEcsWaiter = jest.fn(); const mockCodeDeployCreateDeployment = jest.fn(); const mockCodeDeployGetDeploymentGroup = jest.fn(); const mockCodeDeployWaiter = jest.fn(); +let config = { + region: 'fake-region', +}; + jest.mock('aws-sdk', () => { return { - config: { - region: 'fake-region' - }, + config, ECS: jest.fn(() => ({ registerTaskDefinition: mockEcsRegisterTaskDef, updateService: mockEcsUpdateService, @@ -146,7 +148,7 @@ describe('Deploy to ECS', () => { }); }); - test('registers the task definition contents and updates the service', async () => { + test('registers the task definition contents and updates the service', async () => { await run(); expect(core.setFailed).toHaveBeenCalledTimes(0); expect(mockEcsRegisterTaskDef).toHaveBeenNthCalledWith(1, { family: 'task-def-family'}); @@ -165,6 +167,17 @@ 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('prints Chinese console domain for cn regions', async () => { + const originalRegion = config.region; + config.region = 'cn-fake-region'; + await run(); + + expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.amazonaws.cn/ecs/home?region=cn-fake-region#/clusters/cluster-789/services/service-456/events"); + + // reset + config.region = originalRegion; + }); + test('cleans null keys out of the task definition contents', async () => { fs.readFileSync.mockImplementation((pathInput, encoding) => { if (encoding != 'utf8') {