-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (50 loc) · 1.76 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
name: Build, Test, and Deploy
on:
push:
branches:
- dev
tags:
- 'v[0-9]+.[0-9]+' # eg: v1.1
- 'v[0-9]+.[0-9]+.[0-9]+' # eg: v1.1.1
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- name: set up node.js
uses: actions/setup-node@v3
with:
node-version: '14.17.6'
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install awscli python3-requests
npm install
- name: run lint
run: npm run lint
- name: run test
run: npm run test
- name: set dev settings
if: startsWith(github.ref, 'refs/heads/dev')
run: |
echo "AWS_CF_ID=${{ secrets.AWS_CF_ID_DEV }}" >> $GITHUB_ENV
echo "REACT_APP_MERMAID_API_URL=https://dev-api.datamermaid.org" >> $GITHUB_ENV
echo "DASH_URL=dev-dashboard2.datamermaid.org" >> $GITHUB_ENV
- name: set prod settings
if: startsWith(github.ref, 'refs/tags')
run: |
echo "AWS_CF_ID=${{ secrets.AWS_CF_ID_PROD }}" >> $GITHUB_ENV
echo "REACT_APP_MERMAID_API_URL=https://api.datamermaid.org" >> $GITHUB_ENV
echo "DASH_URL=dashboard2.datamermaid.org" >> $GITHUB_ENV
- name: build and deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'us-east-1'
run: |
export REACT_APP_MERMAID_API_URL=$REACT_APP_MERMAID_API_URL
npm run build
aws s3 sync build/ s3://$DASH_URL/ --delete
aws cloudfront create-invalidation --distribution-id $AWS_CF_ID --paths "/*"