-
Notifications
You must be signed in to change notification settings - Fork 7
98 lines (84 loc) · 3.93 KB
/
deploy.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
88
89
90
91
92
93
94
95
96
97
98
name: Deploy
# Run on pushes to main or PRs
on:
# Pull request hook without any config. Launches for every pull request
pull_request:
# Launches for pushes to main or dev
push:
branches:
- main
- dev
tags:
- v*
# Launches build when release is published
release:
types: [published]
jobs:
deploy:
name: Deployment
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Remove broken apt repos [Ubuntu]
if: ${{ matrix.os }} == 'ubuntu-latest'
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Setup Node.js
uses: actions/setup-node@v2
- name: Install
working-directory: ./website
run: |
rm -rf .cache
rm -rf build
yarn config set cache-folder .yarn
yarn install
pip install awscli --upgrade --user
- name: Build App
working-directory: ./website
run: yarn build
- name: Configure AWS Development credentials
uses: aws-actions/configure-aws-credentials@v1
if: startsWith(github.event.ref, 'refs/heads/dev') || github.event_name == 'refs/heads/main'
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.DEV_AWS_DEFAULT_REGION }}
- name: Configure AWS Production credentials
uses: aws-actions/configure-aws-credentials@v1
if: startsWith(github.event.ref, 'refs/tags/v') || github.event_name == 'release'
with:
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.PROD_AWS_DEFAULT_REGION }}
# Script to deploy to development environment
- name: 'Deploy to S3: Development'
working-directory: ./website
if: github.ref == 'refs/heads/dev'
run: |
aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public
aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/dev --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html
# Script to deploy to staging environment
- name: 'Deploy to S3: Staging'
working-directory: ./website
if: github.ref == 'refs/heads/main'
run: |
aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/staging --exclude "*.html" --cache-control max-age=0,no-cache,no-store,public
aws s3 sync build/ s3://${{ secrets.DEV_BUCKET_NAME }}/staging --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html
# Script to deploy to release environment
- name: 'Deploy to S3: Release'
working-directory: ./website
if: startsWith(github.event.ref, 'refs/tags/v') || github.event_name == 'release'
run: |
aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*.html" --exclude "sitemap.xml" --cache-control max-age=86400,public
aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html
aws s3 sync build/ s3://${{ secrets.RELEASE_BUCKET_NAME }} --delete --exclude "*" --include "sitemap.xml" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/xml