Last active
March 4, 2018 23:01
-
-
Save cristofer-dev/cad71e5dd0bafec4e6e8427b9e9e6828 to your computer and use it in GitHub Desktop.
Build instructions for deploy react app
This file contains hidden or 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 | |
# obtenemos el HASH del commit de MASTER | |
master=$(cat .git/refs/heads/master) | |
echo $master | |
if [ ${#master} = 0 ]; then | |
echo "Imposible encontrar .git/refs/heads/master" | |
fi | |
# Obtenemos el HASH del commit que le llego al BUILD | |
hash=$(echo $CODEBUILD_SOURCE_VERSION | cut -c1-7) | |
echo $hash | |
# Si ambos HASH son iguales, deployamos a PRO caso contrario a DEV | |
if [ $master = $CODEBUILD_SOURCE_VERSION ] && [ ! ${#master} = 0 ] ; then | |
echo "Build to PRODUCTION" | |
STAGE="PRO" | |
bucket=$bucketPro | |
cdn=$cdnPro | |
else | |
echo "Build to DEV" | |
STAGE="DEV" | |
bucket=$bucketDev | |
cdn=$cdnDev | |
fi | |
npm install | |
npm run build | |
cd build | |
# Upload build to s3 | |
aws s3 sync . s3://$bucket --delete --acl public-read \ | |
# Forzando al CDN a recargar sus fuentes | |
aws cloudfront create-invalidation --distribution-id $cdn --paths / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment