From 6ee88c686d32a7eaba172c014995e98cd5e74962 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Tue, 27 Oct 2020 18:04:40 +0530 Subject: [PATCH 1/2] code changed --- master_deploy.sh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/master_deploy.sh b/master_deploy.sh index 45f34a0..5f8c388 100755 --- a/master_deploy.sh +++ b/master_deploy.sh @@ -569,16 +569,34 @@ deploy_s3bucket() { exit 1 fi - S3_OPTIONS="--exclude '*' --include '*.txt' --include '*.js' --include '*.css' --content-encoding gzip" - echo aws s3 sync --dryrun $AWS_S3_SOURCE_SYNC_PATH s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS} - eval "aws s3 sync --dryrun $AWS_S3_SOURCE_SYNC_PATH s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}" - result=`eval "aws s3 sync $AWS_S3_SOURCE_SYNC_PATH s3://${AWS_S3_BUCKET} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}"` - if [ $? -eq 0 ]; then - echo "All txt, css, and js files are Deployed! with gzip" - else - echo "Deployment Failed - $result" - exit 1 - fi + # S3_OPTIONS="--exclude '*' --include '*.txt' --include '*.js' --include '*.css' --content-encoding gzip" + searchpath=${AWS_S3_SOURCE_SYNC_PATH} + lengthofsearchpath=$(echo ${#searchpath}) + lengthofsearchpath=$((lengthofsearchpath+1)) + for syncfilepath in $(find ${searchpath} -name '*.js' -o -name '*.txt' -o -name '*.css'); + do + echo "$syncfilepath" + uploadpath=$(echo $syncfilepath | cut -b ${lengthofsearchpath}-) + echo $uploadpath + getformatdetails=$(file ${syncfilepath}) + if [[ $getformatdetails == *"ASCII"* ]] || [[ $getformatdetails == *"empty"* ]]; + then + echo "file format is ASCII adn skipping gzip option" + S3_OPTIONS="" + else + echo $getformatdetails + S3_OPTIONS="--content-encoding gzip" + fi + echo aws s3 cp --dryrun $syncfilepath s3://${AWS_S3_BUCKET}${uploadpath} ${S3_CACHE_OPTIONS} ${S3_OPTIONS} + eval "aws s3 cp --dryrun $syncfilepath s3://${AWS_S3_BUCKET}${uploadpath} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}" + result=`eval "aws s3 cp $syncfilepath s3://${AWS_S3_BUCKET}${uploadpath} ${S3_CACHE_OPTIONS} ${S3_OPTIONS}"` + if [ $? -eq 0 ]; then + echo "file Deployed!" + else + echo "Deployment Failed - $result" + exit 1 + fi + done; } download_envfile() { From 4304578cc4fe7b481625ff22d144fbe55bea76d1 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Wed, 28 Oct 2020 11:06:16 +0530 Subject: [PATCH 2/2] Update master_deploy.sh --- master_deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master_deploy.sh b/master_deploy.sh index 5f8c388..0572bdd 100755 --- a/master_deploy.sh +++ b/master_deploy.sh @@ -581,7 +581,7 @@ deploy_s3bucket() { getformatdetails=$(file ${syncfilepath}) if [[ $getformatdetails == *"ASCII"* ]] || [[ $getformatdetails == *"empty"* ]]; then - echo "file format is ASCII adn skipping gzip option" + echo "file format is ASCII and skipping gzip option" S3_OPTIONS="" else echo $getformatdetails