Skip to content

Commit ac5e120

Browse files
committed
feat: support pre-built archive
1 parent 3cef5e2 commit ac5e120

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

deploy.sh

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,42 @@ export AWS_ACCESS_KEY_ID=$INPUT_AWS_ACCESS_KEY
4040
export AWS_SECRET_ACCESS_KEY=$INPUT_AWS_SECRET_KEY
4141
export AWS_DEFAULT_REGION=$INPUT_AWS_REGION
4242

43-
# 2) Zip up the package
44-
DIR_TO_ZIP="./$INPUT_DIRECTORY"
45-
if [ ! -f "$DIR_TO_ZIP/appspec.yml" ]; then
46-
echo "::error::appspec.yml was not located at: $DIR_TO_ZIP"
47-
exit 1;
48-
fi
43+
# 2) Zip up the package, if no archive given
44+
if [ -z "$INPUT_ARCHIVE" ]; then
4945

50-
echo "::debug::Zip directory located (with appspec.yml)."
46+
DIR_TO_ZIP="./$INPUT_DIRECTORY"
47+
if [ ! -f "$DIR_TO_ZIP/appspec.yml" ]; then
48+
echo "::error::appspec.yml was not located at: $DIR_TO_ZIP"
49+
exit 1;
50+
fi
5151

52-
ZIP_FILENAME=$GITHUB_RUN_ID-$GITHUB_SHA.zip
52+
echo "::debug::Zip directory located (with appspec.yml)."
5353

54-
# This creates a temp file to explode space delimited excluded files
55-
# into newline delimited exclusions passed to "-x" on the zip command.
56-
EXCLUSION_FILE=$(mktemp /tmp/zip-excluded.XXXXXX)
57-
echo "$INPUT_EXCLUDED_FILES" | tr ' ' '\n' > "$EXCLUSION_FILE"
54+
ZIP_FILENAME=$GITHUB_RUN_ID-$GITHUB_SHA.zip
5855

59-
echo "::debug::Exclusion file created for files to ignore in Zip Generation."
56+
# This creates a temp file to explode space delimited excluded files
57+
# into newline delimited exclusions passed to "-x" on the zip command.
58+
EXCLUSION_FILE=$(mktemp /tmp/zip-excluded.XXXXXX)
59+
echo "$INPUT_EXCLUDED_FILES" | tr ' ' '\n' > "$EXCLUSION_FILE"
6060

61-
if [ -n "$DIR_TO_ZIP" ]; then
62-
cd "$DIR_TO_ZIP";
63-
fi
61+
echo "::debug::Exclusion file created for files to ignore in Zip Generation."
6462

65-
zip -r --quiet "$ZIP_FILENAME" . -x "@$EXCLUSION_FILE"
66-
if [ ! -f "$ZIP_FILENAME" ]; then
67-
echo "::error::$ZIP_FILENAME was not generated properly (zip generation failed)."
68-
exit 1;
63+
if [ -n "$DIR_TO_ZIP" ]; then
64+
cd "$DIR_TO_ZIP";
65+
fi
66+
67+
zip -r --quiet "$ZIP_FILENAME" . -x "@$EXCLUSION_FILE"
68+
if [ ! -f "$ZIP_FILENAME" ]; then
69+
echo "::error::$ZIP_FILENAME was not generated properly (zip generation failed)."
70+
exit 1;
71+
fi
72+
73+
echo "::debug::Zip Archive created."
74+
else
75+
echo "::error::$INPUT_ARCHIVE being using as zip filename. Skipping generation of ZIP."
76+
ZIP_FILENAME="$INPUT_ARCHIVE"
6977
fi
7078

71-
echo "::debug::Zip Archive created."
7279

7380
if [ "$(unzip -l "$ZIP_FILENAME" | grep -q appspec.yml)" = "0" ]; then
7481
echo "::error::$ZIP_FILENAME was not generated properly (missing appspec.yml)."

0 commit comments

Comments
 (0)