-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (75 loc) · 2.42 KB
/
pr.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
name: CI Workflow for PR
on:
pull_request:
branches:
- master
jobs:
pr-prebuild:
name: PR Prebuild
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '21'
- name: Enable Corepack
run: corepack enable
- name: Cache Yarn
uses: actions/cache@v3
with:
path: |
.yarn/
yarn.lock.sha256sum
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: Install Dependencies
run: |
yarn install
- name: Build with sourcemaps
env:
REACT_APP_HTTP_PROTOCOL: ${{ vars.REACT_APP_HTTP_PROTOCOL }}
REACT_APP_API_URL: ${{ vars.REACT_APP_PREVIEW_API_URL }}
REACT_APP_URL: ${{ vars.REACT_APP_PREVIEW_URL }}
REACT_APP_WS_PROTOCOL: ${{ vars.REACT_APP_WS_PROTOCOL }}
CI: false
run: yarn run build_with_sourcemap
- name: Save git hash to version.txt
run: node get_git_hash.js > build/version.txt
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
include-hidden-files: true
path: build/
deploy-s3-pr-preview:
name: Deploy to S3 for PR Preview
runs-on: ubuntu-latest
needs: pr-prebuild
if: github.ref != 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: Zip the build directory
run: |
cd build
find . -name "*.map" -type f -delete
zip -r app.zip .
cd ../
- name: Set up AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'eu-west-3' # Update region if necessary
- name: Deploy to S3
run: |
export BRANCH_HASH=$(git rev-parse --abbrev-ref HEAD | md5sum | awk '{print $1}')
aws s3 rm s3://iseplife-github-prs/$BRANCH_HASH --recursive
aws s3 cp build/ s3://iseplife-github-prs/$BRANCH_HASH --recursive