Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use correct host for China region console #309

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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') {
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
21 changes: 17 additions & 4 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'});
Expand All @@ -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') {
Expand Down