From 9e47aba461c72b6ba9b432f281e4598e70bef579 Mon Sep 17 00:00:00 2001 From: Christos Alexiou Date: Mon, 5 May 2025 23:08:57 +0300 Subject: [PATCH 1/4] Add maxAttempts in API calls --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f5d29bf0..ef5675d3 100644 --- a/index.js +++ b/index.js @@ -454,11 +454,18 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task async function run() { try { + const maxRetries = parseInt(core.getInput('max-retries', { required: false })) || 3; + const ecs = new ECS({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxAttempts: maxRetries, + retryMode: 'standard' }); + const codedeploy = new CodeDeploy({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxAttempts: maxRetries, + retryMode: 'standard' }); // Get inputs From 15e2f641e8f27705eff737b530a8653af768f9cf Mon Sep 17 00:00:00 2001 From: Christos Alexiou Date: Mon, 5 May 2025 23:09:08 +0300 Subject: [PATCH 2/4] Define parameter and update readme --- README.md | 6 ++++++ action.yml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 378af267..da6cf13d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,12 @@ Registers an Amazon ECS task definition and deploys it to an ECS service. ## Usage +The action supports the following inputs: + +* `task-definition` (required) - The path to the ECS task definition file (JSON format) to register. +* `max-retries` (optional) - The maximum number of retry attempts for AWS API calls. The action uses exponential backoff with jitter for retries. Defaults to 3. +* `service` (optional) - The name of the ECS service to update with the new task definition. If empty, the action will not attempt to update a service. + ```yaml - name: Deploy to Amazon ECS uses: aws-actions/amazon-ecs-deploy-task-definition@v2 diff --git a/action.yml b/action.yml index e9cdfc22..0b42ed2c 100644 --- a/action.yml +++ b/action.yml @@ -88,6 +88,9 @@ inputs: propagate-tags: description: "Determines to propagate the tags from the 'SERVICE' to the task." required: false + max-retries: + description: 'The maximum number of retry attempts for AWS API calls. Defaults to 3.' + required: false outputs: task-definition-arn: description: 'The ARN of the registered ECS task definition.' From 67d811229d71478d1d83d1e494c3b324d79cd432 Mon Sep 17 00:00:00 2001 From: Christos Alexiou Date: Mon, 5 May 2025 23:09:11 +0300 Subject: [PATCH 3/4] Package --- dist/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index fa20cd08..90f02415 100644 --- a/dist/index.js +++ b/dist/index.js @@ -460,11 +460,18 @@ async function createCodeDeployDeployment(codedeploy, clusterName, service, task async function run() { try { + const maxRetries = parseInt(core.getInput('max-retries', { required: false })) || 3; + const ecs = new ECS({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxAttempts: maxRetries, + retryMode: 'standard' }); + const codedeploy = new CodeDeploy({ - customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions' + customUserAgent: 'amazon-ecs-deploy-task-definition-for-github-actions', + maxAttempts: maxRetries, + retryMode: 'standard' }); // Get inputs From cdaa7710f2e915450755ad00440bee869c832bb3 Mon Sep 17 00:00:00 2001 From: Christos Alexiou Date: Mon, 5 May 2025 23:24:19 +0300 Subject: [PATCH 4/4] Cleanup docs --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index da6cf13d..dda7c0ae 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,6 @@ Registers an Amazon ECS task definition and deploys it to an ECS service. ## Usage -The action supports the following inputs: - -* `task-definition` (required) - The path to the ECS task definition file (JSON format) to register. -* `max-retries` (optional) - The maximum number of retry attempts for AWS API calls. The action uses exponential backoff with jitter for retries. Defaults to 3. -* `service` (optional) - The name of the ECS service to update with the new task definition. If empty, the action will not attempt to update a service. - ```yaml - name: Deploy to Amazon ECS uses: aws-actions/amazon-ecs-deploy-task-definition@v2 @@ -234,7 +228,7 @@ Running a service requires the following minimum set of permissions: ] } ``` - + Running a one-off/stand-alone task requires the following minimum set of permissions: ```json { @@ -348,7 +342,7 @@ In the following example, the service would not be updated until the ad-hoc task wait-for-task-stopped: true ``` -Overrides and VPC networking options are available as well. See [action.yml](action.yml) for more details. The `FARGATE` +Overrides and VPC networking options are available as well. See [action.yml](action.yml) for more details. The `FARGATE` launch type requires `awsvpc` network mode in your task definition and you must specify a network configuration. ### Tags @@ -372,6 +366,21 @@ To tag your tasks: wait-for-task-stopped: true ``` +### Retries + +To retry a deployment of a task definition use `max-retries`. The default value is `3`. + +```yaml + - name: Deploy to Amazon ECS + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 + with: + task-definition: task-definition.json + service: my-service + cluster: my-cluster + max-retries: 5 + wait-for-service-stability: true +``` + ## Troubleshooting This action emits debug logs to help troubleshoot deployment failures. To see the debug logs, create a secret named `ACTIONS_STEP_DEBUG` with value `true` in your repository.