Skip to content

Commit d7b585a

Browse files
committed
adjust a bunch of crap to get successful deploys on push w reasonable
caching
1 parent 03e8c8d commit d7b585a

9 files changed

+7180
-236
lines changed

.circleci/config.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
deployToStaging:
8+
docker:
9+
- image: circleci/node:10.15.0
10+
11+
working_directory: ~/repo
12+
13+
steps:
14+
- checkout
15+
16+
- run: yarn config set prefix ~/.yarn
17+
18+
# Download and cache dependencies
19+
- restore_cache:
20+
keys:
21+
# when lock file changes, use increasingly general patterns to restore cache
22+
- node-v1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
23+
# - node-v1-{{ .Branch }}-
24+
# - node-v1-
25+
26+
# this has to be a global else amplify craps out don't ask.
27+
# i guess there's probably a way to have yarn not install it if not needed
28+
# but this is quite a bit faster than using `yarn list --patern amplify`
29+
- run: "if [ -e $HOME/.yarn/bin/amplify ]; then echo 'amplify already installed globally, skipping'; else yarn global add @aws-amplify/cli@multienv; fi"
30+
- run: yarn
31+
32+
- save_cache:
33+
paths:
34+
- node_modules
35+
# capture globally installed amplify CLI...it doesn't work
36+
# when executing it locally via node_modules/.bin/amplify so w/e
37+
- ~/.yarn
38+
# previous one symlinks into here
39+
- ~/.config/yarn
40+
key: node-v1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
41+
42+
# amplify doesn't presently support creds as environment variables so
43+
# we write ~/.aws/credentials based on environment variables. ok sure
44+
- run: ./script/write_aws_creds_file.sh
45+
- run: ./script/amplify_init.sh
46+
- run: ~/.yarn/bin/amplify env checkout staging
47+
- run: ~/.yarn/bin/amplify publish -y
48+
49+
workflows:
50+
version: 2
51+
deployToStagingAndTest:
52+
jobs:
53+
- deployToStaging
54+
# at first we will deploy everything but really this should be just for
55+
# PRs against master; uncomment this.
56+
# branches:
57+
# ignore:
58+
# - master

.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ yarn-error.log*
2424

2525
#amplify
2626
amplify/\#current-cloud-backend
27-
amplify/.config/local-*
27+
# amplify/.config/local-*
2828
amplify/backend/amplify-meta.json
2929
aws-exports.js
30-
awsconfiguration.json
30+
awsconfiguration.json

amplify/.config/local-aws-info.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"staging": {
3+
"configLevel": "project",
4+
"useProfile": true,
5+
"profileName": "amplify"
6+
},
7+
"prod": {
8+
"configLevel": "project",
9+
"useProfile": true,
10+
"profileName": "amplify"
11+
}
12+
}

amplify/.config/local-env-info.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"projectPath": "/Users/stuartsan/dev/lighthouse-circleci-example",
3+
"envName": "staging"
4+
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "lighthouse-circleci-example",
3-
"version": "0.1.0",
3+
"version": "0.1.4",
44
"private": true,
55
"dependencies": {
6+
"@aws-amplify/cli": "^0.2.1-multienv.35",
67
"aws-amplify": "^1.1.19",
78
"aws-amplify-react": "^2.3.0",
89
"react": "^16.7.0",

script/amplify_init.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
IFS='|'
4+
5+
REACTCONFIG="{\
6+
\"SourceDir\":\"src\",\
7+
\"DistributionDir\":\"build\",\
8+
\"BuildCommand\":\"npm run-script build\",\
9+
\"StartCommand\":\"npm run-script start\"\
10+
}"
11+
AWSCLOUDFORMATIONCONFIG="{\
12+
\"configLevel\":\"project\",\
13+
\"useProfile\":true,\
14+
\"profileName\":\"amplify\",\
15+
\"region\":\"us-west-2\"\
16+
}"
17+
AMPLIFY="{\
18+
\"projectName\":\"lighthousecircleciex\",\
19+
\"defaultEditor\":\"code\"\
20+
}"
21+
FRONTEND="{\
22+
\"frontend\":\"javascript\",\
23+
\"framework\":\"react\",\
24+
\"config\":$REACTCONFIG\
25+
}"
26+
PROVIDERS="{\
27+
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
28+
}"
29+
30+
~/.yarn/bin/amplify configure project \
31+
--amplify $AMPLIFY \
32+
--frontend $FRONTEND \
33+
--providers $PROVIDERS \

script/write_aws_creds_file.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
mkdir -p ~/.aws/
4+
5+
cat <<EOF > ~/.aws/credentials
6+
[amplify]
7+
aws_access_key_id=$AWS_ACCESS_KEY_AMPLIFY
8+
aws_secret_access_key=$AWS_SECRET_KEY_AMPLIFY
9+
EOF
10+
11+
cat <<EOF > ~/.aws/config
12+
[profile amplify]
13+
region=us-west-2
14+
EOF

0 commit comments

Comments
 (0)