Last active
February 18, 2022 16:07
-
-
Save goosys/3585da30df31e88b6eb00c161a450071 to your computer and use it in GitHub Desktop.
Deploying Amplify App via CI
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
amplify/ | |
aws-exports.js |
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 | |
set -e | |
IFS='|' | |
AWS_PROFILE="your_aws_profile" | |
PROJECT_NAME="amplify_project_name" | |
APP_ID="amplify_app_id" | |
if [[ "${AWS_ACCESS_KEY_ID:+x}" && "${AWS_SECRET_ACCESS_KEY:+x}" ]]; then | |
AWSCREDENTIALS="\"useProfile\":false,\ | |
\"accessKeyId\":\"$AWS_ACCESS_KEY_ID\",\ | |
\"secretAccessKey\":\"$AWS_SECRET_ACCESS_KEY\"," | |
else | |
AWSCREDENTIALS="\"useProfile\":true,\"profileName\":\"$AWS_PROFILE\"," | |
fi | |
REACTCONFIG="{\ | |
\"SourceDir\":\"src\",\ | |
\"DistributionDir\":\"build\",\ | |
\"BuildCommand\":\"npm run-script build\",\ | |
\"StartCommand\":\"npm run-script start\"\ | |
}" | |
AWSCLOUDFORMATIONCONFIG="{\ | |
\"configLevel\":\"project\",\ | |
$AWSCREDENTIALS\ | |
\"region\":\"ap-northeast-1\"\ | |
}" | |
AMPLIFY="{\ | |
\"projectName\":\"$PROJECT_NAME\",\ | |
\"appId\":\"$APP_ID\",\ | |
\"envName\":\"$1\",\ | |
\"defaultEditor\":\"code\"\ | |
}" | |
FRONTEND="{\ | |
\"frontend\":\"javascript\",\ | |
\"framework\":\"react-native\",\ | |
\"config\":$REACTCONFIG\ | |
}" | |
PROVIDERS="{\ | |
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\ | |
}" | |
rm -rf amplify src/aws-exports.js | |
echo n | amplify pull \ | |
--amplify $AMPLIFY \ | |
--frontend $FRONTEND \ | |
--providers $PROVIDERS | |
# Thanks | |
# https://github.com/aws-amplify/amplify-cli/issues/5275#issuecomment-724069616 | |
# https://github.com/aws-amplify/amplify-cli/issues/3292#issuecomment-788249445 | |
# https://docs.amplify.aws/cli/usage/headless#amplify-pull-parameters |
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 | |
set -e | |
IFS='|' | |
if which amplify >/dev/null; then | |
: | |
else | |
npm install --quiet -g @aws-amplify/cli | |
fi | |
if [[ $EAS_BUILD_PROFILE == "production" ]]; then | |
./bin/amplify-setup prd | |
else | |
./bin/amplify-setup stg | |
fi |
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
{ | |
"main": "index.js", | |
"scripts": { | |
"start": "expo start --dev-client", | |
"android": "expo run:android --device", | |
"ios": "expo run:ios --device", | |
"init:clean": "rm -rf src/* amplify .expo/* android ios", | |
"init:amplify": "yarn init:amplify:test", | |
"init:amplify:test": "bin/amplify-setup test", | |
"init:amplify:stg": "bin/amplify-setup stg", | |
"init:amplify:prd": "bin/amplify-setup prd", | |
"build:ios:stg": "eas build -p ios --profile preview", | |
"build:android:stg": "eas build -p android --profile preview", | |
"build:ios:prd": "eas build -p ios --profile production", | |
"build:android:prd": "eas build -p android --profile production", | |
"eas-build-pre-install": "./bin/eas-build-pre-install" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment