Skip to content

Commit

Permalink
adjust a bunch of crap to get successful deploys on push w reasonable
Browse files Browse the repository at this point in the history
caching
  • Loading branch information
stuartsan committed Jan 23, 2019
1 parent 03e8c8d commit d7b585a
Show file tree
Hide file tree
Showing 9 changed files with 7,180 additions and 236 deletions.
58 changes: 58 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
deployToStaging:
docker:
- image: circleci/node:10.15.0

working_directory: ~/repo

steps:
- checkout

- run: yarn config set prefix ~/.yarn

# Download and cache dependencies
- restore_cache:
keys:
# when lock file changes, use increasingly general patterns to restore cache
- node-v1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
# - node-v1-{{ .Branch }}-
# - node-v1-

# this has to be a global else amplify craps out don't ask.
# i guess there's probably a way to have yarn not install it if not needed
# but this is quite a bit faster than using `yarn list --patern amplify`
- run: "if [ -e $HOME/.yarn/bin/amplify ]; then echo 'amplify already installed globally, skipping'; else yarn global add @aws-amplify/cli@multienv; fi"
- run: yarn

- save_cache:
paths:
- node_modules
# capture globally installed amplify CLI...it doesn't work
# when executing it locally via node_modules/.bin/amplify so w/e
- ~/.yarn
# previous one symlinks into here
- ~/.config/yarn
key: node-v1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}

# amplify doesn't presently support creds as environment variables so
# we write ~/.aws/credentials based on environment variables. ok sure
- run: ./script/write_aws_creds_file.sh
- run: ./script/amplify_init.sh
- run: ~/.yarn/bin/amplify env checkout staging
- run: ~/.yarn/bin/amplify publish -y

workflows:
version: 2
deployToStagingAndTest:
jobs:
- deployToStaging
# at first we will deploy everything but really this should be just for
# PRs against master; uncomment this.
# branches:
# ignore:
# - master
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yarn-error.log*

#amplify
amplify/\#current-cloud-backend
amplify/.config/local-*
# amplify/.config/local-*
amplify/backend/amplify-meta.json
aws-exports.js
awsconfiguration.json
awsconfiguration.json
12 changes: 12 additions & 0 deletions amplify/.config/local-aws-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"staging": {
"configLevel": "project",
"useProfile": true,
"profileName": "amplify"
},
"prod": {
"configLevel": "project",
"useProfile": true,
"profileName": "amplify"
}
}
4 changes: 4 additions & 0 deletions amplify/.config/local-env-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"projectPath": "/Users/stuartsan/dev/lighthouse-circleci-example",
"envName": "staging"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "lighthouse-circleci-example",
"version": "0.1.0",
"version": "0.1.4",
"private": true,
"dependencies": {
"@aws-amplify/cli": "^0.2.1-multienv.35",
"aws-amplify": "^1.1.19",
"aws-amplify-react": "^2.3.0",
"react": "^16.7.0",
Expand Down
33 changes: 33 additions & 0 deletions script/amplify_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -e
IFS='|'

REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"amplify\",\
\"region\":\"us-west-2\"\
}"
AMPLIFY="{\
\"projectName\":\"lighthousecircleciex\",\
\"defaultEditor\":\"code\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

~/.yarn/bin/amplify configure project \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
14 changes: 14 additions & 0 deletions script/write_aws_creds_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

mkdir -p ~/.aws/

cat <<EOF > ~/.aws/credentials
[amplify]
aws_access_key_id=$AWS_ACCESS_KEY_AMPLIFY
aws_secret_access_key=$AWS_SECRET_KEY_AMPLIFY
EOF

cat <<EOF > ~/.aws/config
[profile amplify]
region=us-west-2
EOF
Loading

0 comments on commit d7b585a

Please sign in to comment.