Skip to content

Commit 337a48e

Browse files
committed
Create github workflow to deploy frontend to S3
* Ensure that action triggers only on push to main and on any changes to frontend directory * Uploads contents in dist folder to s3 bucket
1 parent 1ffbe7d commit 337a48e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/frontend.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy Frontend
2+
3+
on:
4+
push:
5+
branches: [ 'main' ]
6+
paths:
7+
- 'frontend/**' # Only trigger if changes are made in the frontend directory
8+
pull_request:
9+
10+
workflow_dispatch:
11+
12+
permissions:
13+
id-token: write # This is required for requesting the JWT
14+
contents: read # This is required for actions/checkout
15+
16+
env:
17+
AWS_REGION: ap-southeast-1
18+
S3_BUCKET_NAME: app.peerprep.org
19+
20+
jobs:
21+
deploy:
22+
name: Deploy Frontend
23+
runs-on: ubuntu-latest
24+
environment: production
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Configure AWS credentials
30+
id: aws-configure
31+
uses: aws-actions/[email protected]
32+
with:
33+
role-to-assume: arn:aws:iam::491085383176:role/github_s3_copy
34+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
35+
aws-region: ${{ env.AWS_REGION }}
36+
37+
- name: Build frontend distribution
38+
working-directory: frontend
39+
run: npm ci && npm run build
40+
41+
- name: Sync distribution to S3
42+
run: |
43+
aws s3 sync ./frontend/dist/frontend/browser/ s3://$S3_BUCKET_NAME --delete

0 commit comments

Comments
 (0)