Skip to content

Commit f712cce

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 f712cce

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/frontend.yml

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

0 commit comments

Comments
 (0)