-
Notifications
You must be signed in to change notification settings - Fork 17
49 lines (43 loc) · 1.58 KB
/
frontdeploy.yaml
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
name: Deploy frontend
on:
push:
branches:
- main
paths:
- "client/**"
- ".github/workflows/frontdeploy.yaml"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: "**/client/node_modules"
key: ${{ runner.os }}-v2-${{ hashFiles('**/client/package-lock.json') }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "21.x"
- name: Install dependencies
working-directory: ./client
run: npm install
- name: Replace version
working-directory: ./client
run: |
export GIT_HASH=$(git rev-parse --short HEAD)
export VITE_APP_DATE_VERSION=$(date -u +'%Y-%m-%d')
sed -i "s|VITE_APP_DATE_VERSION=local|VITE_APP_DATE_VERSION=${GIT_HASH}|g" .env
sed -i "s|VITE_APP_VERSION=local|VITE_APP_VERSION=${GIT_HASH}|g" .env
- name: Production build
working-directory: ./client
run: npm run build
- name: Synchronize files
working-directory: ./client
run: |
export AWS_ACCESS_KEY_ID=${{ secrets.CI_CD_AWS_ACCESS_KEY_ID }}
export AWS_SECRET_ACCESS_KEY=${{ secrets.CI_CD_AWS_SECRET_ACCESS_KEY }}
export AWS_DEFAULT_REGION=${{ secrets.AWS_DEFAULT_REGION }}
aws configure set preview.cloudfront true
aws s3 sync dist s3://${{ secrets.AWS_S3_BUCKET }} --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths /\*