Last active
June 18, 2016 01:00
-
-
Save johncmckim/397c89fa46c203a7e7bac5ff23410e21 to your computer and use it in GitHub Desktop.
Serverless v0.5 Deploy
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
#!/bin/bash | |
if [[ $TRAVIS_TEST_RESULT == 1 ]]; then | |
echo 'Skipping deploy due to broken build'; | |
exit 1; | |
fi | |
echo 'Starting deploy' | |
if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then | |
if [[ $TRAVIS_BRANCH == 'master' ]]; then | |
STAGE="prod" | |
elif [[ $TRAVIS_BRANCH == 'develop' ]]; then | |
STAGE="dev" | |
fi | |
fi | |
echo "Deploying stage from branch $TRAVIS_BRANCH to $STAGE" | |
if [ -z ${STAGE+x} ]; then | |
echo "Not deploying changes"; | |
exit 0; | |
fi | |
# There's probably better ways to do this but it works | |
function run { | |
cmd="$@" | |
echo "Running '$cmd'" | |
$cmd | |
local status=$? | |
if [ $status -ne 0 ]; then | |
echo "Error with $1" >&2 | |
exit 1; | |
fi | |
return $status | |
} | |
function runSls { | |
slsCmd="sls $@ -s $STAGE -r $REGION" | |
run $slsCmd | |
} | |
LOCAL_META_VAR_FILE="_meta/variables/s-variables-$STAGE-$REGION_VAR_NAME.json" | |
S3_META_VAR_FILE="s3://$META_SYNC_BUCKET/serverless/$PROJECT/variables/s-variables-$STAGE-$REGION_VAR_NAME.json" | |
echo "Will copy metadata from $LOCAL_META_VAR_FILE to $S3_META_VAR_FILE" | |
runSls "project init -c" | |
runSls "meta sync" # get new variables | |
runSls "resources deploy" | |
run "aws s3 cp $LOCAL_META_VAR_FILE $S3_META_VAR_FILE" # store new variables | |
runSls "function deploy -a" | |
runSls "event deploy -a" | |
runSls "endpoint deploy -a" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment