Skip to content

Add support for maxAttempts to allow retrying after failure #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,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
{
Expand Down Expand Up @@ -342,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
Expand All @@ -366,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.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
11 changes: 9 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down