diff --git a/action.yml b/action.yml index a18b581ad..e56764836 100644 --- a/action.yml +++ b/action.yml @@ -52,6 +52,9 @@ inputs: run-task-started-by: description: "A name to use for the startedBy tag when running a task outside of a service. Will default to 'GitHub-Actions'." required: false + run-task-assign-public-ip: + description: "A boolean indicating whether to assign a public IP to the task." + required: false wait-for-task-stopped: description: 'Whether to wait for the task to stop when running it outside of a service. Will default to not wait.' required: false diff --git a/dist/index.js b/dist/index.js index 67713e72f..3e0007fb3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -201,6 +201,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE'; const subnetIds = core.getInput('run-task-subnets', { required: false }) || ''; const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || ''; + const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || ''; const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]'); let awsvpcConfiguration = {} @@ -212,6 +213,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',') } + if (assignPublicIp != "") { + awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED" + } + const runTaskResponse = await ecs.runTask({ startedBy: startedBy, cluster: clusterName, @@ -227,11 +232,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { const taskArns = runTaskResponse.tasks.map(task => task.taskArn); core.setOutput('run-task-arn', taskArns); - - taskArns.map(taskArn => { - let taskId = taskArn.split('/').pop(); - core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`) - }); + core.info(`Task running: https://console.aws.amazon.com/ecs/home?region=${aws.config.region}#/clusters/${clusterName}/tasks`); if (runTaskResponse.failures && runTaskResponse.failures.length > 0) { const failure = runTaskResponse.failures[0]; @@ -485,9 +486,11 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task } } }; + // If it hasn't been set then we don't even want to pass it to the api call to maintain previous behaviour. if (codeDeployDescription) { - deploymentParams.description = codeDeployDescription + // CodeDeploy Deployment Descriptions have a max length of 512 characters, so truncate if necessary + deploymentParams.description = (codeDeployDescription.length <= 512) ? codeDeployDescription : `${codeDeployDescription.substring(0,511)}…`; } const createDeployResponse = await codedeploy.createDeployment(deploymentParams).promise(); core.setOutput('codedeploy-deployment-id', createDeployResponse.deploymentId); diff --git a/index.js b/index.js index b3dee9f4a..3aac12b2c 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE'; const subnetIds = core.getInput('run-task-subnets', { required: false }) || ''; const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || ''; + const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || ''; const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]'); let awsvpcConfiguration = {} @@ -40,6 +41,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',') } + if (assignPublicIp != "") { + awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED" + } + const runTaskResponse = await ecs.runTask({ startedBy: startedBy, cluster: clusterName,