-
Notifications
You must be signed in to change notification settings - Fork 252
45 lines (43 loc) · 1.61 KB
/
frontend.beta.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
name: Build and deploy frontend
on:
push:
branches: [ master ]
jobs:
build-frontend:
runs-on: ubuntu-latest
if: github.repository == 'pschlan/cron-job.org'
environment:
name: beta
url: https://console.beta.cron-job.org
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./frontend/package-lock.json
- run: 'echo "$FRONTEND_CONFIG" > ./src/utils/Config.js'
shell: bash
env:
FRONTEND_CONFIG: ${{secrets.FRONTEND_CONFIG}}
working-directory: ./frontend
- run: npm ci
working-directory: ./frontend
- run: npm run build
working-directory: ./frontend
- name: Deploy to S3/CloudFront
run: |
aws s3 sync ./build s3://$FRONTEND_S3_BUCKET --exclude "*.map" --exclude "index.html"
aws s3 cp ./build/index.html s3://$FRONTEND_S3_BUCKET/index.html --metadata-directive REPLACE --cache-control max-age=0,s-maxage=86400 --content-type text/html
aws cloudfront create-invalidation --distribution-id $FRONTEND_CF_DISTRIBUTION_ID --paths "/*"
working-directory: ./frontend
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-1
FRONTEND_S3_BUCKET: ${{ secrets.FRONTEND_S3_BUCKET }}
FRONTEND_CF_DISTRIBUTION_ID: ${{ secrets.FRONTEND_CF_DISTRIBUTION_ID }}