Skip to content

Commit 87f4b19

Browse files
authored
Merge pull request #12 from zappan/feature/tgz-bundle-support
Feature/tgz bundle support
2 parents 4f671aa + 3c78e47 commit 87f4b19

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Environment variables are used to control the deployment actions. A brief summar
126126
| `AWS_CODE_DEPLOY_EC2_TAG_FILTERS` | No | EC2 tags to filter on when creating a deployment group |
127127
| `AWS_CODE_DEPLOY_AUTO_SCALING_GROUPS` | No | Auto Scaling groups when creating a deployment group |
128128
| `AWS_CODE_DEPLOY_APP_SOURCE` | **Yes** | The source directory used to create the deploy archive or a pre-bundled tar, tgz, or zip |
129+
| `AWS_CODE_DEPLOY_APP_BUNDLE_TYPE` | No | Deploy bundle type when created from source directory (`tgz` or `zip`). Default: `zip`)
129130
| `AWS_CODE_DEPLOY_S3_BUCKET` | **Yes** | The name of the S3 bucket to deploy the revision |
130131
| `AWS_CODE_DEPLOY_S3_KEY_PREFIX` | No | A prefix to use for the revision bucket key |
131132
| `AWS_CODE_DEPLOY_S3_FILENAME` | **Yes** | The destination name within S3. |

bin/aws-code-deploy.sh

+25-8
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ fi
329329

330330
# ----- Application Source -----
331331
h1 "Step 6: Checking Application Source"
332+
AWS_CODE_DEPLOY_APP_BUNDLE_TYPE=${AWS_CODE_DEPLOY_APP_BUNDLE_TYPE:-zip}
332333
APP_SOURCE=$(readlink -f "${AWS_CODE_DEPLOY_APP_SOURCE:-.}")
333334

334335
if [ ! -d "$APP_SOURCE" -a ! -e "$APP_SOURCE" ]; then
@@ -341,19 +342,35 @@ if [ -d "$APP_SOURCE" ]; then
341342
error "The specified source directory \"${APP_SOURCE}\" does not contain an \"appspec.yml\" in the application root."
342343
exit 1
343344
fi
344-
if ! typeExists "zip"; then
345-
note "Installing zip binaries ..."
346-
sudo apt-get install -y zip
347-
note "Zip binaries installed."
345+
if [ $AWS_CODE_DEPLOY_APP_BUNDLE_TYPE == "tgz" ]; then
346+
if ! typeExists "tar" -o ! typeExists "gzip"; then
347+
note "Installing tar and gzip binaries ..."
348+
sudo apt-get install -y tar gzip
349+
note "Tar and GZip binaries installed."
350+
fi
351+
BUNDLE_EXTENSION="tar.gz"
352+
else ## defaults to zip
353+
if ! typeExists "zip"; then
354+
note "Installing zip binaries ..."
355+
sudo apt-get install -y zip
356+
note "Zip binaries installed."
357+
fi
358+
BUNDLE_EXTENSION="zip"
348359
fi
349360
DEPLOYMENT_COMPRESS_ORIG_DIR_SIZE=$(du -hs $APP_SOURCE | awk '{ print $1}')
350-
APP_LOCAL_FILE="${AWS_CODE_DEPLOY_S3_FILENAME%.*}.zip"
361+
APP_LOCAL_FILE="${AWS_CODE_DEPLOY_S3_FILENAME%.*}.${BUNDLE_EXTENSION}"
351362
APP_LOCAL_TEMP_FILE="/tmp/$APP_LOCAL_FILE"
352363

353-
runCommand "cd \"$APP_SOURCE\" && zip -rq \"${APP_LOCAL_TEMP_FILE}\" ." \
354-
"Unable to compress \"$APP_SOURCE\""
364+
if [ $AWS_CODE_DEPLOY_APP_BUNDLE_TYPE == "tgz" ]; then
365+
runCommand "tar -zcvf \"${APP_LOCAL_TEMP_FILE}\" -C \"$APP_SOURCE\" ." \
366+
"Unable to compress \"$APP_SOURCE\""
367+
BUNDLE_TYPE="tgz"
368+
else ## defaults to zip
369+
runCommand "cd \"$APP_SOURCE\" && zip -rq \"${APP_LOCAL_TEMP_FILE}\" ." \
370+
"Unable to compress \"$APP_SOURCE\""
371+
BUNDLE_TYPE="zip"
372+
fi
355373
DEPLOYMENT_COMPRESS_FILESIZE=$(ls -lah "${APP_LOCAL_TEMP_FILE}" | awk '{ print $5}')
356-
BUNDLE_TYPE="zip"
357374
success "Successfully compressed \"$APP_SOURCE\" ($DEPLOYMENT_COMPRESS_ORIG_DIR_SIZE) into \"$APP_LOCAL_FILE\" ($DEPLOYMENT_COMPRESS_FILESIZE)"
358375
else
359376
APP_SOURCE_BASENAME=$(basename "$APP_SOURCE")

0 commit comments

Comments
 (0)