Skip to content

Commit 256cf35

Browse files
bennettp123vikasperiiBotPeaches
authored
Add support for *.tar and *.tar.gz archives (#73)
* add support for .tar, .tar.gz archives * add dependencies tar & gzip * fix bundleType mismatch * fix incorrect doco link in comment * Update deploy.sh * add bundle_type to action.yaml * fix unquoted var, handle bundle_type input * Typo: ecas -> esac * remove bundle_type infer bundle_type from filename (remove input) * fix linting error https://www.shellcheck.net/wiki/SC2143 -- was already using `grep -qv`, not sure why I wrapped it in `[ -n ... ]` (: --------- Co-authored-by: vikasperi <117131235+vikasperi@users.noreply.github.com> Co-authored-by: Connor Tumbleson <iBotPeaches@users.noreply.github.com>
1 parent d87d8a4 commit 256cf35

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ COPY cleanup.sh /cleanup.sh
66

77
# Get tools needed for packaging
88
RUN yum update -y \
9-
&& yum install -y zip unzip jq \
9+
&& yum install -y zip unzip jq tar gzip \
1010
&& yum clean all

deploy.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,31 @@ else
8383
fi
8484

8585

86-
if [ "$(unzip -l "$ZIP_FILENAME" | grep -q appspec.yml)" = "0" ]; then
87-
echo "::error::$ZIP_FILENAME was not generated properly (missing appspec.yml)."
88-
exit 1;
86+
BUNDLE_TYPE=''
87+
# permitted values for BUNDLE_TYPE can be found here: https://docs.aws.amazon.com/codedeploy/latest/userguide/application-revisions-push.html#push-with-cli
88+
case "$ZIP_FILENAME" in
89+
*.tar)
90+
BUNDLE_TYPE=tar
91+
;;
92+
*.tar.gz)
93+
BUNDLE_TYPE=tgz
94+
;;
95+
*)
96+
# assume it's a zipfile
97+
BUNDLE_TYPE=zip
98+
;;
99+
esac
100+
101+
if [ "$BUNDLE_TYPE" == 'zip' ]; then
102+
if [ "$(unzip -l "$ZIP_FILENAME" | grep -q appspec.yml)" = "0" ]; then
103+
echo "::error::$ZIP_FILENAME was not generated properly (missing appspec.yml)."
104+
exit 1;
105+
fi
106+
else
107+
if tar -tf "$ZIP_FILENAME" | grep -qv appspec.yml; then
108+
echo "::error::$ZIP_FILENAME was not generated properly (missing appspec.yml)."
109+
exit 1;
110+
fi
89111
fi
90112

91113
echo "::debug::Zip Archived validated."
@@ -192,14 +214,14 @@ function deployRevision() {
192214
--application-name "$INPUT_CODEDEPLOY_NAME" \
193215
--deployment-group-name "$INPUT_CODEDEPLOY_GROUP" \
194216
--description "$GITHUB_REF - $GITHUB_SHA" \
195-
--s3-location bucket="$INPUT_S3_BUCKET",bundleType=zip,eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" | jq -r '.deploymentId'
217+
--s3-location bucket="$INPUT_S3_BUCKET",bundleType="$BUNDLE_TYPE",eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" | jq -r '.deploymentId'
196218
}
197219

198220
function registerRevision() {
199221
aws deploy register-application-revision \
200222
--application-name "$INPUT_CODEDEPLOY_NAME" \
201223
--description "$GITHUB_REF - $GITHUB_SHA" \
202-
--s3-location bucket="$INPUT_S3_BUCKET",bundleType=zip,eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" > /dev/null 2>&1
224+
--s3-location bucket="$INPUT_S3_BUCKET",bundleType="$BUNDLE_TYPE",eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" > /dev/null 2>&1
203225
}
204226

205227
if $INPUT_CODEDEPLOY_REGISTER_ONLY; then

0 commit comments

Comments
 (0)