-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (77 loc) · 2.29 KB
/
front-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
name: Deploy Frontend
on:
workflow_call:
inputs:
api-url:
required: true
description: 'URL of the API'
type: string
secrets:
AWS_S3_BUCKET:
description: 'Bucket name where the build will be deployed'
required: true
AWS_ACCESS_KEY_ID:
description: 'Access key ID of the account with rights'
required: true
AWS_SECRET_ACCESS_KEY:
description: 'Secret key of the account with rights'
required: true
DISTRIBUTION:
description: 'AWS distribution name that needs to be invalidated'
required: true
env:
VITE_APP_API_HOST: ${{inputs.api-url}}
root-path: front/www
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
fail-fast: false
defaults:
run:
working-directory: ./${{ env.root-path }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install
- name: Run Tests
run: yarn test
- name: Build Project
run: yarn build
- name: Archive Build
uses: actions/upload-artifact@v2
with:
name: dist
path: ${{ env.root-path }}/dist
deployment:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Dist
uses: actions/download-artifact@v2
with:
name: dist
path: ${{ env.root-path }}/dist
- uses: jakejarvis/s3-sync-action@master
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
SOURCE_DIR: '${{ env.root-path }}/dist'
- uses: chetan/invalidate-cloudfront-action@v2
env:
PATHS: '/*'
AWS_REGION: 'us-east-1'
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}