diff --git a/action.yml b/action.yml index e1f7db5b6..2adfd4721 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,9 @@ inputs: force-new-deployment: description: 'Whether to force a new deployment of the service. Valid value is "true". Will default to not force a new deployment.' required: false + max-retries: + description: 'Number of times to retry AWS API requests when encountering network or rate-limit errors. Default is 3.' + required: false outputs: task-definition-arn: description: 'The ARN of the registered ECS task definition' diff --git a/dist/index.js b/dist/index.js index a3345ba7e..ed02d87bc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -260,18 +260,12 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task async function run() { try { - const ecs = new aws.ECS({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' - }); - const codedeploy = new aws.CodeDeploy({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' - }); - // Get inputs const taskDefinitionFile = core.getInput('task-definition', { required: true }); const service = core.getInput('service', { required: false }); const cluster = core.getInput('cluster', { required: false }); const waitForService = core.getInput('wait-for-service-stability', { required: false }); + const maxRetries = core.getInput('max-retries', { required: false }) || 3; let waitForMinutes = parseInt(core.getInput('wait-for-minutes', { required: false })) || 30; if (waitForMinutes > MAX_WAIT_MINUTES) { waitForMinutes = MAX_WAIT_MINUTES; @@ -282,6 +276,15 @@ async function run() { const desiredCount = parseInt((core.getInput('desired-count', {required: false}))); + const ecs = new aws.ECS({ + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxRetries + }); + const codedeploy = new aws.CodeDeploy({ + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxRetries + }); + // Register the task definition core.debug('Registering the task definition'); const taskDefPath = path.isAbsolute(taskDefinitionFile) ? diff --git a/index.js b/index.js index ff5f57c93..ffb866eb3 100644 --- a/index.js +++ b/index.js @@ -254,18 +254,12 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task async function run() { try { - const ecs = new aws.ECS({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' - }); - const codedeploy = new aws.CodeDeploy({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' - }); - // Get inputs const taskDefinitionFile = core.getInput('task-definition', { required: true }); const service = core.getInput('service', { required: false }); const cluster = core.getInput('cluster', { required: false }); const waitForService = core.getInput('wait-for-service-stability', { required: false }); + const maxRetries = core.getInput('max-retries', { required: false }) || 3; let waitForMinutes = parseInt(core.getInput('wait-for-minutes', { required: false })) || 30; if (waitForMinutes > MAX_WAIT_MINUTES) { waitForMinutes = MAX_WAIT_MINUTES; @@ -276,6 +270,15 @@ async function run() { const desiredCount = parseInt((core.getInput('desired-count', {required: false}))); + const ecs = new aws.ECS({ + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxRetries + }); + const codedeploy = new aws.CodeDeploy({ + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxRetries + }); + // Register the task definition core.debug('Registering the task definition'); const taskDefPath = path.isAbsolute(taskDefinitionFile) ?