Skip to content

Instantly share code, notes, and snippets.

@thedgbrt
Created September 25, 2019 10:46
Show Gist options
  • Save thedgbrt/11158b45df9bc79dd0e8869b5412b19d to your computer and use it in GitHub Desktop.
Save thedgbrt/11158b45df9bc79dd0e8869b5412b19d to your computer and use it in GitHub Desktop.
Temporary alternative to amplifyPush.sh
#!/bin/bash
set -e
IFS='|'
# if no provided environment name, use default env variable, then user override
if [[ ${ENV} = "" ]];
then
ENV=${AWS_BRANCH}
fi
if [[ ${USER_BRANCH} != "" ]];
then
ENV=${USER_BRANCH}
fi
# Check valid environment name
if [[ -z ${ENV} || "${ENV}" =~ [^a-zA-Z0-9\-]+ ]] ; then help_output ; fi
REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"default\"\
}"
AMPLIFY="{\
\"envName\":\"${ENV}\",\
\"defaultEditor\":\"sublime\"\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
echo "# Initializing ampliy environment: ${ENV}"
amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
echo "# Regenerating API Files (sometimes missing)"
amplify api gql-compile
echo "# Updating remote environment"
amplify push -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment