7
7
const path = __nccwpck_require__(1017);
8
8
const core = __nccwpck_require__(2186);
9
9
const { CodeDeploy, waitUntilDeploymentSuccessful } = __nccwpck_require__(6692);
10
- const { ECS, waitUntilServicesStable } = __nccwpck_require__(8209);
10
+ const { ECS, waitUntilServicesStable, waitUntilTasksStopped } = __nccwpck_require__(8209);
11
11
const yaml = __nccwpck_require__(4083);
12
12
const fs = __nccwpck_require__(7147);
13
13
const crypto = __nccwpck_require__(6113);
@@ -55,18 +55,18 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
55
55
containerOverrides: containerOverrides
56
56
},
57
57
launchType: launchType,
58
- networkConfiguration: awsvpcConfiguration === {} ? {} : { awsvpcConfiguration: awsvpcConfiguration }
59
- }).promise() ;
58
+ networkConfiguration: Object.keys( awsvpcConfiguration).length === 0 ? {} : { awsvpcConfiguration: awsvpcConfiguration }
59
+ });
60
60
61
61
core.debug(`Run task response ${JSON.stringify(runTaskResponse)}`)
62
62
63
63
const taskArns = runTaskResponse.tasks.map(task => task.taskArn);
64
64
core.setOutput('run-task-arn', taskArns);
65
65
66
- taskArns.map(taskArn => {
67
- let taskId = taskArn.split('/').pop() ;
68
- core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`)
69
- } );
66
+ const region = await ecs.config.region();
67
+ const consoleHostname = region.startsWith('cn') ? 'console.amazonaws.cn' : 'console.aws.amazon.com' ;
68
+
69
+ core.info(`Task running: https://${consoleHostname}/ecs/home?region=${region}#/clusters/${clusterName}/tasks` );
70
70
71
71
if (runTaskResponse.failures && runTaskResponse.failures.length > 0) {
72
72
const failure = runTaskResponse.failures[0];
@@ -90,14 +90,14 @@ async function waitForTasksStopped(ecs, clusterName, taskArns, waitForMinutes) {
90
90
91
91
core.info(`Waiting for tasks to stop. Will wait for ${waitForMinutes} minutes`);
92
92
93
- const waitTaskResponse = await ecs.waitFor('tasksStopped', {
93
+ const waitTaskResponse = await waitUntilTasksStopped({
94
+ client: ecs,
95
+ minDelay: WAIT_DEFAULT_DELAY_SEC,
96
+ maxWaitTime: waitForMinutes * 60,
97
+ }, {
94
98
cluster: clusterName,
95
99
tasks: taskArns,
96
- $waiter: {
97
- delay: WAIT_DEFAULT_DELAY_SEC,
98
- maxAttempts: (waitForMinutes * 60) / WAIT_DEFAULT_DELAY_SEC
99
- }
100
- }).promise();
100
+ });
101
101
102
102
core.debug(`Run task response ${JSON.stringify(waitTaskResponse)}`);
103
103
core.info('All tasks have stopped.');
@@ -108,7 +108,7 @@ async function tasksExitCode(ecs, clusterName, taskArns) {
108
108
const describeResponse = await ecs.describeTasks({
109
109
cluster: clusterName,
110
110
tasks: taskArns
111
- }).promise() ;
111
+ });
112
112
113
113
const containers = [].concat(...describeResponse.tasks.map(task => task.containers))
114
114
const exitCodes = containers.map(container => container.exitCode)
@@ -330,9 +330,11 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task
330
330
}
331
331
}
332
332
};
333
+
333
334
// If it hasn't been set then we don't even want to pass it to the api call to maintain previous behaviour.
334
335
if (codeDeployDescription) {
335
- deploymentParams.description = codeDeployDescription
336
+ // CodeDeploy Deployment Descriptions have a max length of 512 characters, so truncate if necessary
337
+ deploymentParams.description = (codeDeployDescription.length <= 512) ? codeDeployDescription : `${codeDeployDescription.substring(0,511)}…`;
336
338
}
337
339
if (codeDeployConfig) {
338
340
deploymentParams.deploymentConfigName = codeDeployConfig
0 commit comments