Skip to content

Commit b489eca

Browse files
committed
feat: Add assignPublicIp Input
1 parent ab77eed commit b489eca

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ inputs:
5252
run-task-started-by:
5353
description: "A name to use for the startedBy tag when running a task outside of a service. Will default to 'GitHub-Actions'."
5454
required: false
55+
run-task-assign-public-ip:
56+
description: "A boolean indicating whether to assign a public IP to the task."
57+
required: false
5558
wait-for-task-stopped:
5659
description: 'Whether to wait for the task to stop when running it outside of a service. Will default to not wait.'
5760
required: false

dist/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
201201
const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE';
202202
const subnetIds = core.getInput('run-task-subnets', { required: false }) || '';
203203
const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || '';
204+
const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || '';
204205
const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]');
205206
let awsvpcConfiguration = {}
206207

@@ -212,6 +213,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
212213
awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',')
213214
}
214215

216+
if (assignPublicIp != "") {
217+
awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED"
218+
}
219+
215220
const runTaskResponse = await ecs.runTask({
216221
startedBy: startedBy,
217222
cluster: clusterName,
@@ -227,11 +232,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
227232

228233
const taskArns = runTaskResponse.tasks.map(task => task.taskArn);
229234
core.setOutput('run-task-arn', taskArns);
230-
231-
taskArns.map(taskArn => {
232-
let taskId = taskArn.split('/').pop();
233-
core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`)
234-
});
235+
core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`);
235236

236237
if (runTaskResponse.failures && runTaskResponse.failures.length > 0) {
237238
const failure = runTaskResponse.failures[0];
@@ -485,9 +486,11 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task
485486
}
486487
}
487488
};
489+
488490
// If it hasn't been set then we don't even want to pass it to the api call to maintain previous behaviour.
489491
if (codeDeployDescription) {
490-
deploymentParams.description = codeDeployDescription
492+
// CodeDeploy Deployment Descriptions have a max length of 512 characters, so truncate if necessary
493+
deploymentParams.description = (codeDeployDescription.length <= 512) ? codeDeployDescription : `${codeDeployDescription.substring(0,511)}…`;
491494
}
492495
const createDeployResponse = await codedeploy.createDeployment(deploymentParams).promise();
493496
core.setOutput('codedeploy-deployment-id', createDeployResponse.deploymentId);

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
2929
const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE';
3030
const subnetIds = core.getInput('run-task-subnets', { required: false }) || '';
3131
const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || '';
32+
const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || '';
3233
const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]');
3334
let awsvpcConfiguration = {}
3435

@@ -40,6 +41,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
4041
awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',')
4142
}
4243

44+
if (assignPublicIp != "") {
45+
awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED"
46+
}
47+
4348
const runTaskResponse = await ecs.runTask({
4449
startedBy: startedBy,
4550
cluster: clusterName,

0 commit comments

Comments
 (0)