-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (62 loc) · 2.38 KB
/
deploy.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
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
name: Deploy Workflow
on:
release: { types: [published] }
workflow_dispatch:
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
# Permissions required to use aws-actions/configure-aws-credentials:
permissions: { id-token: write, contents: read }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- run: npm ci --include=dev
- name: Build
env:
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
VITE_SENTRY_CI_RELEASE_NAME: ${{ github.event.release.name }}
VITE_STRIPE_PUBLISHABLE_KEY: ${{ secrets.STRIPE_TEST_PUBLISHABLE_KEY }}
VITE_GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
run: |
if [[ "${{ github.event_name }}" == 'release' && "${{ github.event.release.prerelease }}" == 'false' ]]; then
npm run build
else
npm run build:staging
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.S3_OIDC_GITHUB_ROLE_ARN }}
aws-region: ${{ secrets.S3_BUCKET_REGION }}
- name: Upload to S3
run: |
if [[ "${{ github.event_name }}" == 'release' && "${{ github.event.release.prerelease }}" == 'false' ]]; then
bucket_dir='production'
else
bucket_dir='staging'
fi
aws s3 sync ./dist \
s3://${{ secrets.S3_BUCKET_NAME }}/$bucket_dir \
--acl bucket-owner-full-control \
--sse AES256 \
--delete \
1>/dev/null
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CLOUDFRONT_OIDC_GITHUB_ROLE_ARN }}
aws-region: ${{ secrets.CLOUDFRONT_DIST_REGION }}
- name: Invalidate CloudFront Edge-Cache
run: |
if [[ "${{ github.event_name }}" == 'release' && "${{ github.event.release.prerelease }}" == 'false' ]]; then
cf_dist_id=${{ secrets.CLOUDFRONT_PROD_DIST_ID }}
else
cf_dist_id=${{ secrets.CLOUDFRONT_STAGING_DIST_ID }}
fi
aws cloudfront create-invalidation \
--distribution-id $cf_dist_id \
--paths '/*' \
1>/dev/null