-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (66 loc) · 2.06 KB
/
production.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
name: Build and Deploy to Production
on:
workflow_dispatch:
inputs:
reason:
description: 'Manual Deployment Reason'
required: false
default: 'Rebuild gatsby'
push:
branches:
- master
jobs:
ping-dev-server:
name: Ping Prod server
runs-on: ubuntu-latest
steps:
- name: Ping dev api
run: curl ${{ secrets.PROD_STRAPI_API_URL }}
lint-and-test:
name: Syntax check (Eslint) and Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: yarn
- name: Run Eslint
run: yarn lint
# - name: Run Tests
# run: yarn test
build-and-deploy:
name: Build and deploy the site to staging
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: yarn
- name: Build website
env:
REACT_APP_STRAPI_API: ${{ secrets.PROD_STRAPI_API_URL }}
REACT_APP_FRONT_END_URL: ${{ secrets.PROD_REACT_APP_FRONT_END_URL }}
run: CI=false yarn build
- name: Deploy to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --delete
env:
AWS_S3_BUCKET: ${{ secrets.PROD_AWS_BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: 'build'
invalidate:
name: Invalidate cloudfront cache
runs-on: ubuntu-latest
needs: build-and-deploy
steps:
- uses: actions/checkout@v1
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Invalidate cache
run: aws cloudfront create-invalidation --distribution-id "${{ secrets.PROD_CLOUD_FRONT_DISTRIBUTION }}" --paths "/*"