diff --git a/Dockerfile b/Dockerfile index 50b1b2f..9280015 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM amazon/aws-cli:2.14.2 +FROM amazon/aws-cli:2.27.11 # Move files in for deployment & cleanup COPY deploy.sh /deploy.sh diff --git a/README.md b/README.md index 1f1471b..cdd547d 100644 --- a/README.md +++ b/README.md @@ -62,23 +62,24 @@ permissions: Following inputs can be used as `step.with` keys -| Name | Required | Type | Description | -|----------------------------|----------|---------|-----------------------------------------------------------------| -| `aws_access_key` | No | String | IAM Access Key. | -| `aws_secret_key` | No | String | IAM Secret Key. | -| `aws_region` | No | String | AWS Region (default: `us-east-1`). | -| `codedeploy_name` | Yes | String | CodeDeploy Project Name. | -| `codedeploy_group` | Yes | String | CodeDeploy Project Group. | -| `codedeploy_config_name` | No | String | If provided, override the default CodeDeploy Configuration name | -| `codedeploy_register_only` | No | Boolean | If true, revision is registered not deployed. | -| `s3_bucket` | Yes | String | S3 Bucket for archive to be uploaded. | -| `s3_folder` | Yes | String | S3 Folder for archive to be uploaded within bucket. | -| `excluded_files` | No | String | Space delimited list of patterns to exclude from archive | -| `directory` | No | String | Directory to archive. Defaults to root of project. | -| `custom_zip_flags` | No | String | Flags to pass to `zip` command. (ie `zip "$FLAGS" ...`) | -| `archive` | No | String | Zip to deploy. Defaults to empty (thus ignored) | -| `max_polling_iterations` | No | Number | Number of 15s iterations to poll max. (default: `60`) | -| `dry_run` | No | Boolean | If true, no connection to AWS is made. Just local zip creation. | +| Name | Required | Type | Description | +|-----------------------------------|----------|---------|-------------------------------------------------------------------| +| `aws_access_key` | No | String | IAM Access Key. | +| `aws_secret_key` | No | String | IAM Secret Key. | +| `aws_region` | No | String | AWS Region (default: `us-east-1`). | +| `codedeploy_name` | Yes | String | CodeDeploy Project Name. | +| `codedeploy_group` | Yes | String | CodeDeploy Project Group. | +| `codedeploy_config_name` | No | String | If provided, override the default CodeDeploy Configuration name | +| `codedeploy_register_only` | No | Boolean | If true, revision is registered not deployed. | +| `codedeploy_file_exists_behavior` | No | String | If provided, override the default CodeDeploy File Exists Behavior | +| `s3_bucket` | Yes | String | S3 Bucket for archive to be uploaded. | +| `s3_folder` | Yes | String | S3 Folder for archive to be uploaded within bucket. | +| `excluded_files` | No | String | Space delimited list of patterns to exclude from archive | +| `directory` | No | String | Directory to archive. Defaults to root of project. | +| `custom_zip_flags` | No | String | Flags to pass to `zip` command. (ie `zip "$FLAGS" ...`) | +| `archive` | No | String | Zip to deploy. Defaults to empty (thus ignored) | +| `max_polling_iterations` | No | Number | Number of 15s iterations to poll max. (default: `60`) | +| `dry_run` | No | Boolean | If true, no connection to AWS is made. Just local zip creation. | ### outputs @@ -162,4 +163,4 @@ For deploying via CodeDeploy you will need another set of permissions. ``` * These permissions are a rough example of allowing the user to list/get/register a revision for all resources - * A specific permission statement exists to lock creating the deployment to a specific resource + * A specific permission statement exists to lock creating the deployment to a specific resource \ No newline at end of file diff --git a/action.yaml b/action.yaml index af5feab..fe55497 100644 --- a/action.yaml +++ b/action.yaml @@ -47,6 +47,10 @@ inputs: description: 'Whether to register the deployment (vs automatic deploy).' required: false default: 'false' + codedeploy_file_exists_behavior: + description: 'What to do if the file already exists in the deployment location. Possible options are DISSALOW|OVERWRITE|RETAIN' + required: false + default: 'DISALLOW' max_polling_iterations: description: 'Max amount of iterations (15s increments) to wait for a deployment' required: false diff --git a/deploy.sh b/deploy.sh index 825fc0c..72ced8d 100755 --- a/deploy.sh +++ b/deploy.sh @@ -20,6 +20,7 @@ function deployRevision() { --application-name "$INPUT_CODEDEPLOY_NAME" \ --deployment-group-name "$INPUT_CODEDEPLOY_GROUP" \ --description "$GITHUB_REF - $GITHUB_SHA" \ + --file-exists-behavior "$INPUT_CODEDEPLOY_FILE_EXISTS_BEHAVIOR" \ --s3-location bucket="$INPUT_S3_BUCKET",bundleType="$BUNDLE_TYPE",eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" | jq -r '.deploymentId' } @@ -51,7 +52,7 @@ function pollForSpecificDeployment() { while true; do RESPONSE=$(getSpecificDeployment "$1") - FAILED_COUNT=$(echo "$RESPONSE" | jq -r '.deploymentInfo.deploymentOverview.Failed') + FAILED_COUNT=$(echo "$RESPONSE" | jq -r '.deploymentInfo.deploymentOverview.Failed // "?"') IN_PROGRESS_COUNT=$(echo "$RESPONSE" | jq -r '.deploymentInfo.deploymentOverview.InProgress') SKIPPED_COUNT=$(echo "$RESPONSE" | jq -r '.deploymentInfo.deploymentOverview.Skipped') SUCCESS_COUNT=$(echo "$RESPONSE" | jq -r '.deploymentInfo.deploymentOverview.Succeeded') @@ -59,12 +60,18 @@ function pollForSpecificDeployment() { STATUS=$(echo "$RESPONSE" | jq -r '.deploymentInfo.status') echo -e "${ORANGE}Deployment in progress. Sleeping 15 seconds. (Try $((++deadlockCounter)))"; - echo -e "Instance Overview: ${RED}Failed ($FAILED_COUNT), ${BLUE}In-Progress ($IN_PROGRESS_COUNT), ${RESET_TEXT}Skipped ($SKIPPED_COUNT), ${BLUE}Pending ($PENDING_COUNT), ${GREEN}Succeeded ($SUCCESS_COUNT)" - echo -e "Deployment Status: $STATUS" - if [ "$FAILED_COUNT" -gt 0 ]; then - echo -e "${RED}Failed instance detected (Failed count over zero)." - exit 1; + if [ "$FAILED_COUNT" == "?" ]; then + echo -e "Instance Overview: ${ORANGE}Currently Provisioning..." + echo -e "Deployment Status: $STATUS" + else + echo -e "Instance Overview: ${RED}Failed ($FAILED_COUNT), ${BLUE}In-Progress ($IN_PROGRESS_COUNT), ${RESET_TEXT}Skipped ($SKIPPED_COUNT), ${BLUE}Pending ($PENDING_COUNT), ${GREEN}Succeeded ($SUCCESS_COUNT)" + echo -e "Deployment Status: $STATUS" + + if [ "$FAILED_COUNT" -gt 0 ]; then + echo -e "${RED}Failed instance detected (Failed count over zero)." + exit 1; + fi fi if [ "$STATUS" = "Failed" ]; then @@ -80,6 +87,7 @@ function pollForSpecificDeployment() { echo -e "${RED}Max polling iterations reached (max_polling_iterations)." exit 1; fi + sleep 15s; done; } @@ -179,7 +187,7 @@ case "$ZIP_FILENAME" in *.tar) BUNDLE_TYPE=tar ;; - *.tar.gz) + *.tar.gz|*.tgz) BUNDLE_TYPE=tgz ;; *)