-
Notifications
You must be signed in to change notification settings - Fork 24
86 lines (73 loc) · 3.03 KB
/
copy-react-demo-s3.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
name: Copy React Demo to S3 bucket
on:
push:
branches:
- main
paths:
- '.github/workflows/copy-react-demo-s3.yml'
- 'sample-apps/react/react-video-demo/**'
- '!packages/**' # avoid duplicated deployment if react-sdk also changed
pull_request:
types:
- opened
- synchronize
- reopened
workflow_dispatch:
jobs:
build-and-copy:
runs-on: ubuntu-latest
env:
VITE_STREAM_API_KEY: ${{ vars.EGRESS_STREAM_API_KEY }}
VITE_STREAM_TOKEN: ${{ secrets.EGRESS_USER_TOKEN }}
VITE_STREAM_KEY: ${{ vars.VIDEO_DEMO_STREAM_API_KEY }}
VITE_STREAM_SECRET: ${{ secrets.VIDEO_DEMO_STREAM_SECRET }}
VITE_VIDEO_USER_ID: ${{vars.VIDEO_DEMO_USER_ID}}
VITE_VIDEO_USER_NAME: ${{vars.VIDEO_DEMO_USER_NAME}}
VITE_VIDEO_USER_TOKEN: ${{secrets.VIDEO_DEMO_USER_TOKEN}}
VITE_MAPBOX_GL_TOKEN: ${{secrets.VIDEO_DEMO_MAPBOX_GL_TOKEN}}
VITE_VIDEO_DEMO_SENTRY_DNS: ${{secrets.VIDEO_DEMO_SENTRY_DNS}}
VITE_TOKEN_PROVIDER_URL: ${{secrets.TOKEN_PROVIDER_URL}}
VITE_GTM_ID: ${{ secrets.VIDEO_DEMO_GTM_ID }}
VITE_GTM_PROJECT: ${{ vars.VIDEO_DEMO_GTM_PROJECT }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Install Dependencies
run: yarn install --immutable
- name: Build packages
run: NODE_ENV=production yarn build:react:deps
- name: Build React Demo staging
if: ${{ github.ref_name != 'main' }}
run: yarn build:react:video-demo --mode staging
- name: Build React Demo production
if: ${{ github.ref_name == 'main' }}
run: yarn build:react:video-demo --mode production
- name: Setup 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: ${{vars.AWS_REGION}}
- name: Copy PR build artifacts to AWS S3 Bucket
if: ${{ github.ref_name != 'main' }}
run: |
aws s3 sync sample-apps/react/react-video-demo/dist s3://${{secrets.S3_BUCKET_NAME_STAGING}}/video/demos --delete
- name: Copy main build artifacts to AWS S3 Bucket
if: ${{ github.ref_name == 'main' }}
run: |
aws s3 sync sample-apps/react/react-video-demo/dist s3://${{secrets.S3_BUCKET_NAME_PRODUCTION}}/video/demos --delete
- name: Invalidate Cloudfront cache (staging)
if: ${{ github.ref_name != 'main' }}
run: |
aws cloudfront create-invalidation --distribution-id ${{secrets.AWS_DISTRIBUTION_ID_STAGING}} --paths "/video/demos/*"
- name: Invalidate Cloudfront cache (production)
if: ${{ github.ref_name == 'main' }}
run: |
aws cloudfront create-invalidation --distribution-id ${{secrets.AWS_DISTRIBUTION_ID_PRODUCTION}} --paths "/video/demos/*"