-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (45 loc) · 1.59 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: CD
on: [push]
env:
CLOUDTRUTH_API_KEY: ${{ secrets.CLOUDTRUTH_API_KEY }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup operation environment
run: |
branch=${GITHUB_REF##*/}
if [[ "$branch" == "master" ]]; then
env="production"
else
env="development"
fi
echo "ENV=${env}" >> $GITHUB_ENV
- name: Install cloudtruth cli
uses: cloudtruth/cli-action@v1
- uses: cloudtruth/configure-action@v1
with:
token: "${{ secrets.CLOUDTRUTH_API_KEY }}"
project: "deploy"
environment: "${{ env.ENV }}"
overwrite: true
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install Packages
run: yarn install
# Note that contents of .env are exposed in webapp, so while we treat the
# TID as secret, it technically doesn't have to be
- name: Configure react
run: |
cloudtruth -e ${ENV} --project deploy template get web_dotenv > .env
cloudtruth -e ${ENV} --project web template get dotenv >> .env
cloudtruth -e ${ENV} --project web template get app.live_config > public/web.app.live_config.json
- name: Build react
run: yarn build
- name: Deploy to S3
run: |
aws s3 sync build/ s3://${WEB_BUCKET_NAME}/
aws cloudfront create-invalidation --distribution-id ${WEB_DISTRIBUTION_ID} --paths /index.html /asset-manifest.json /manifest.json