Skip to content

Commit 38fdba9

Browse files
committed
feat: Add assignPublicIp Input
1 parent 6ed3327 commit 38fdba9

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
@@ -35,6 +35,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
3535
const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE';
3636
const subnetIds = core.getInput('run-task-subnets', { required: false }) || '';
3737
const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || '';
38+
const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || '';
3839
const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]');
3940
let awsvpcConfiguration = {}
4041

@@ -46,6 +47,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
4647
awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',')
4748
}
4849

50+
if (assignPublicIp != "") {
51+
awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED"
52+
}
53+
4954
const runTaskResponse = await ecs.runTask({
5055
startedBy: startedBy,
5156
cluster: clusterName,
@@ -61,11 +66,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
6166

6267
const taskArns = runTaskResponse.tasks.map(task => task.taskArn);
6368
core.setOutput('run-task-arn', taskArns);
64-
65-
taskArns.map(taskArn => {
66-
let taskId = taskArn.split('/').pop();
67-
core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`)
68-
});
69+
core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`);
6970

7071
if (runTaskResponse.failures && runTaskResponse.failures.length > 0) {
7172
const failure = runTaskResponse.failures[0];
@@ -322,9 +323,11 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task
322323
}
323324
}
324325
};
326+
325327
// If it hasn't been set then we don't even want to pass it to the api call to maintain previous behaviour.
326328
if (codeDeployDescription) {
327-
deploymentParams.description = codeDeployDescription
329+
// CodeDeploy Deployment Descriptions have a max length of 512 characters, so truncate if necessary
330+
deploymentParams.description = (codeDeployDescription.length <= 512) ? codeDeployDescription : `${codeDeployDescription.substring(0,511)}…`;
328331
}
329332
const createDeployResponse = await codedeploy.createDeployment(deploymentParams).promise();
330333
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)