From fcb3508607a94ca16851eefeba0635c725238df6 Mon Sep 17 00:00:00 2001 From: Andrew Schmadel Date: Tue, 8 Aug 2023 14:10:52 -0400 Subject: [PATCH 1/2] add support for configurable retry-count --- action.yml | 3 +++ index.js | 17 ++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index c8e5b47ee..522c36d69 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,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/index.js b/index.js index 7f759a088..6f2d31c46 100644 --- a/index.js +++ b/index.js @@ -249,18 +249,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; @@ -269,6 +263,15 @@ async function run() { const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false'; const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true'; + 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) ? From 87f4d8e7cd5f6aaadc539df2abee0a35e8392924 Mon Sep 17 00:00:00 2001 From: Andrew Schmadel Date: Tue, 8 Aug 2023 14:21:13 -0400 Subject: [PATCH 2/2] repackage --- dist/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6e1dfd4bb..c90fe5741 100644 --- a/dist/index.js +++ b/dist/index.js @@ -255,18 +255,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; @@ -275,6 +269,15 @@ async function run() { const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false'; const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true'; + 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) ?