-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (68 loc) · 2.89 KB
/
build.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Build
on:
push:
branches: [staging, master, ep-upgrade-stage, ep-upgrade-prod, ep-upgrade]
pull_request:
branches: [staging, master, ep-upgrade-stage, ep-upgrade-prod, ep-upgrade]
permissions:
id-token: write
contents: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.10.0
- name: Install Dependencies
run: yarn install --immutable --immutable-cache
- name: Lint Check
run: yarn lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Help Codecov detect commit SHA
fetch-depth: 2
- uses: actions/setup-node@v2
with:
node-version: 16.10.0
- name: Install Dependencies
run: yarn install --immutable --immutable-cache
- name: Run Tests
run: yarn test
- name: Upload Codecov Reports
uses: codecov/codecov-action@v2
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ (github.ref == 'refs/heads/master' && 'production') || (github.ref == 'refs/heads/ep-upgrade-stage' && 'nonprod') || 'staging' }}
needs: [lint, test]
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/ep-upgrade-stage')
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.10.0
- name: Install Dependencies
run: yarn install --immutable --immutable-cache
- name: Build App
env:
S3_GIVE_DOMAIN: //${{ secrets.GIVE_WEB_HOSTNAME }}
ROLLBAR_ACCESS_TOKEN: ${{ secrets.ROLLBAR_ACCESS_TOKEN }}
run: yarn run build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@036a4a1ddf2c0e7a782dca6e083c6c53e5d90321
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
# Deploying to S3 with the --delete flag can be problematic if a cached file references a deleted file
# Solution: deploy once without deleting old files, invalidate the Cloudfront cache, then deploy a second time with the flag to delete previous files
- name: Deploy to S3
run: aws s3 sync dist s3://${{ secrets.AWS_WEB_STATIC_BUCKET_NAME }} --region us-east-1 --acl public-read --cache-control 'public, max-age=300'
- name: AWS Cloudfront
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
- name: Deploy to S3 and Delete Previous Files
run: aws s3 sync dist s3://${{ secrets.AWS_WEB_STATIC_BUCKET_NAME }} --region us-east-1 --acl public-read --cache-control 'public, max-age=300' --delete