-
Notifications
You must be signed in to change notification settings - Fork 10
122 lines (97 loc) · 4.08 KB
/
deploy-to-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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Deploy to S3
on:
push:
branches:
- dev
tags:
- '*'
env:
environment: ${{ startsWith(github.ref, 'refs/tags/v') && 'UN' || 'dev' }}
jobs:
install_and_build:
runs-on: ubuntu-latest
env:
CI: false
environment:
name: ${{ startsWith(github.ref, 'refs/tags/v') && 'UN' || 'dev' }}
url: ${{ env.environment == 'UN' && 'https://test.uncefact.org/vckit/explorer/' || 'https://explorer.vckit.showthething.com/' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install pnpm
run: npm install -g [email protected]
- name: pnpm version
run: pnpm --version
- name: Install dependencies
run: pnpm install
- name: 'Create env file'
run: |
touch packages/demo-explorer/.env
echo REACT_APP_WALLET_ENDPOINT=${{ vars.REACT_APP_WALLET_ENDPOINT }} >> packages/demo-explorer/.env
echo REACT_APP_ENCRYPTED_ENDPOINT=${{ vars.REACT_APP_ENCRYPTED_ENDPOINT}} >> packages/demo-explorer/.env
echo REACT_APP_QRCODE_VERIFY_ENDPOINT=${{ vars.REACT_APP_QRCODE_VERIFY_ENDPOINT }} >> packages/demo-explorer/.env
echo REACT_APP_SCHEMA_URL=${{ vars.REACT_APP_SCHEMA_URL }} >> packages/demo-explorer/.env
echo REACT_APP_REMOTE_AGENT_API_KEY=${{ vars.REACT_APP_REMOTE_AGENT_API_KEY }} >> packages/demo-explorer/.env
echo REACT_APP_DEFAULT_AGENT_ID=${{ vars.REACT_APP_DEFAULT_AGENT_ID }} >> packages/demo-explorer/.env
cat packages/demo-explorer/.env
- name: Build explorer
run: PUBLIC_URL=${{ env.environment == 'UN' && '/vckit/explorer/' || '/' }} pnpm build:js
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: explorer
path: packages/demo-explorer/build/explorer
deploy_to_s3:
needs: install_and_build
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: ${{ startsWith(github.ref, 'refs/tags/v') && 'UN' || 'dev' }}
url: ${{ env.environment == 'UN' && 'https://test.uncefact.org/vckit/explorer/' || 'https://explorer.vckit.showthething.com/' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: explorer
path: packages/demo-explorer/build/explorer
- name: Install AWS CLI
run: |
sudo apt-get -q install -y python3-pip
pip3 install awscli --upgrade --user
- name: Configure AWS Credentials
if: ${{ env.environment == 'dev' }}
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_GITHUB_ACTION_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- name: Configure AWS Credentials
if: ${{ env.environment == 'UN' }}
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_GITHUB_ACTION_ARN }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Deploy to S3
run: |
S3_PATH=${{ env.environment == 'UN' && '/vckit/explorer/' || '/'}}
aws s3 sync packages/demo-explorer/build/explorer/ s3://${{ vars.AWS_S3_BUCKET_NAME }}$S3_PATH --delete
- name: Invalidate CloudFront
run: |
DISTRIBUTION_ID=${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_ID }}
INVALIDATION_PATH=${{ env.environment == 'UN' && '/vckit/explorer/*' || '/*'}}
# Create a new CloudFront invalidation
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths $INVALIDATION_PATH