-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (109 loc) · 4.01 KB
/
deploy-preview.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: deploy-preview
on:
workflow_call:
pull_request:
types:
- opened
- synchronize
permissions:
id-token: write
contents: read
jobs:
test:
uses: ./.github/workflows/test.yml
smart-camera-web:
needs: [test]
defaults:
run:
working-directory: ./packages/smart-camera-web
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- name: set node version
uses: actions/setup-node@v4
- name: install dependencies
run: npm ci
- name: build application
run: npm run build
- name: set destination directory
id: set_dest_dir_smart_camera_web
run: >-
echo "DEST_DIR_SMART_CAMERA_WEB=js/preview-$GITHUB_HEAD_REF" >>
"$GITHUB_ENV"
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: deploy preview to s3
run: |
aws s3 sync --follow-symlinks --delete --exclude '*' --include 'smart-camera-web.js' . s3://${{ secrets.AWS_S3_BUCKET }}/${{ env.DEST_DIR_SMART_CAMERA_WEB }}
embed:
needs: [test]
defaults:
run:
working-directory: ./packages/embed
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- name: set node version
uses: actions/setup-node@v4
- name: install dependencies
run: npm ci
- name: build application
env:
SENTRY_AUTH_TOKEN: '${{ secrets.SENTRY_AUTH_TOKEN }}'
run: npm run build && npm run build:dist
- name: set destination directory
id: set_dest_dir_hosted_web
run: echo "DEST_DIR_EMBED=inline/preview-$GITHUB_HEAD_REF" >> "$GITHUB_ENV"
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: deploy preview to s3
run: |
aws s3 sync --follow-symlinks --delete dist s3://${{ secrets.AWS_S3_BUCKET }}/${{ env.DEST_DIR_EMBED }}
full-stack:
needs: [embed]
if: always()
defaults:
run:
working-directory: ./previews
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: set sst stage
id: get_branch_name
run: |
BRANCH_NAME=${{ github.event.pull_request.head.ref }}
SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g')
echo "SST_STAGE=$SANITIZED_BRANCH_NAME" >> $GITHUB_OUTPUT
- name: install dependencies
run: npm install
- name: build application
run: npm run build
- name: configure sst secrets
run: |
npm run sst secret set PartnerId ${{ secrets.PREVIEW_PARTNER_ID }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
npm run sst secret set CallbackUrl ${{ secrets.PREVIEW_CALLBACK_URL }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
npm run sst secret set SmileIdApiKey ${{ secrets.PREVIEW_SMILEID_API_KEY }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }} &&
npm run sst secret set SmileIdEnvironment ${{ secrets.PREVIEW_SMILEID_ENVIRONMENT }} --stage ${{ steps.get_branch_name.outputs.SST_STAGE }}
- name: deploy sst app
if: github.event.pull_request.merged != true
id: deploy_sst_app
run: |
npm run sst deploy --stage=${{ steps.get_branch_name.outputs.SST_STAGE }}
- name: remove sst app
if: github.event.pull_request.merged == true
run: |
npm run sst remove --stage=${{ steps.get_branch_name.outputs.SST_STAGE }}