From dd9eeb6155a32b1c39898179e75c5c9b5f593f9b Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 14 Jun 2021 07:46:03 -0400 Subject: [PATCH 1/3] docs: support new "dry_run" feature --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b77ecb4..f7c45ad 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Following inputs can be used as `step.with` keys | `directory` | No | String | Directory to archive. Defaults to root of project. | | `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. | ## Archive or Build Some projects may have a complex build system or even build the archive in a previous step. This is where From baed3ef6b6f41958516837f636be1976b2820a8b Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 14 Jun 2021 07:47:06 -0400 Subject: [PATCH 2/3] build: add new dry_run feature --- action.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yaml b/action.yaml index 3075336..3644ad9 100644 --- a/action.yaml +++ b/action.yaml @@ -45,6 +45,10 @@ inputs: description: 'Max amount of iterations (15s increments) to wait for a deployment' required: false default: '60' + dry_run: + description: 'Whether to skip all AWS related steps.' + required: false + default: 'false' runs: using: 'docker' image: 'Dockerfile' From 9c56b433eb2bfce444916b5fd4ff25b8c1aa1f57 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 14 Jun 2021 07:47:18 -0400 Subject: [PATCH 3/3] feat: skip aws steps if dry_run enabled --- deploy.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/deploy.sh b/deploy.sh index e8bc1c3..bcfbece 100755 --- a/deploy.sh +++ b/deploy.sh @@ -8,27 +8,27 @@ ORANGE='\033[0;33m' BLUE='\033[0;34m' # 0) Validation -if [ -z "$INPUT_CODEDEPLOY_NAME" ]; then +if [ -z "$INPUT_CODEDEPLOY_NAME" ] && [ -z "$INPUT_DRY_RUN" ]; then echo "::error::codedeploy_name is required and must not be empty." exit 1; fi -if [ -z "$INPUT_CODEDEPLOY_GROUP" ]; then +if [ -z "$INPUT_CODEDEPLOY_GROUP" ] && [ -z "$INPUT_DRY_RUN" ]; then echo "::error::codedeploy_group is required and must not be empty." exit 1; fi -if [ -z "$INPUT_AWS_ACCESS_KEY" ]; then +if [ -z "$INPUT_AWS_ACCESS_KEY" ] && [ -z "$INPUT_DRY_RUN" ]; then echo "::error::aws_access_key is required and must not be empty." exit 1; fi -if [ -z "$INPUT_AWS_SECRET_KEY" ]; then +if [ -z "$INPUT_AWS_SECRET_KEY" ] && [ -z "$INPUT_DRY_RUN" ]; then echo "::error::aws_secret_key is required and must not be empty." exit 1; fi -if [ -z "$INPUT_S3_BUCKET" ]; then +if [ -z "$INPUT_S3_BUCKET" ] && [ -z "$INPUT_DRY_RUN" ]; then echo "::error::s3_bucket is required and must not be empty." exit 1; fi @@ -93,6 +93,11 @@ function getArchiveETag() { --query ETag --output text } +if "$INPUT_DRY_RUN"; then + echo "::debug::Dry Run detected. Exiting." + exit 0; +fi + aws s3 cp "$ZIP_FILENAME" s3://"$INPUT_S3_BUCKET"/"$INPUT_S3_FOLDER"/"$ZIP_FILENAME" echo "::debug::Zip uploaded to S3."