Last active
January 4, 2019 11:24
-
-
Save useless-stuff/3e195f9639d2b321cbe74c557a69292d to your computer and use it in GitHub Desktop.
SERVERLESS - Deploy application script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Cleanup | |
rm -rf ./build | |
rm -rf ./dist/src | |
# Create directory structure | |
mkdir -p ./build | |
mkdir -p ./dist | |
# Set correct node version | |
unset PREFIX | |
source ~/.nvm/nvm.sh | |
nvm use 8.10 | |
# Compile TS | |
if tsc ; then | |
echo "TS compiled" | |
else | |
echo "TS failed to compile" | |
exit | |
fi | |
# Build | |
cd dist | |
if ! cmp "../package.json" "./package.json"; | |
then | |
echo "package is different, installing a new version" | |
cp ../package.json ./ | |
yarn install --production=true --pure-lockfile | |
fi | |
# Zip build | |
zip -r ../build/build.zip ./ >/dev/null | |
cd .. | |
ROCKET="🚀" | |
# Deploy | |
DEVELOPER=$(awk -F'=' '/^DEVELOPER_PROFILE/ { print $2}' .env) | |
if [ -z "$1" ] | |
then | |
echo "${ROCKET} Deploying all functions" | |
sls deploy --stage ${DEVELOPER} | |
else | |
echo "${ROCKET} Deploying function $1" | |
sls deploy -f $1 --stage ${DEVELOPER} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment