Skip to content

Commit 374df88

Browse files
committed
Merge branch 'dev' into piotr-introduce-typescript
# Conflicts: # frontend/vite.config.js
2 parents cf91602 + 753826c commit 374df88

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Frontend Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- staging
8+
- demo
9+
- prod
10+
paths:
11+
- 'frontend/**'
12+
- '.github/workflows/deploy-frontend.yaml'
13+
14+
permissions:
15+
id-token: write
16+
contents: read
17+
18+
jobs:
19+
build_and_deploy:
20+
runs-on: ubuntu-latest
21+
environment: ${{ github.ref == 'refs/heads/prod' && 'prod' || github.ref == 'refs/heads/staging' && 'staging' || github.ref == 'refs/heads/dev' && 'dev' }}
22+
env:
23+
PRODUCT: wallet
24+
APPLICATION: frontend
25+
AWS_DEFAULT_REGION: eu-west-1
26+
BUILD_DIR: ./frontend/build
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
35+
- name: Set dev ENV
36+
if: github.ref == 'refs/heads/dev'
37+
run: |
38+
echo "ENV=dev" >> $GITHUB_ENV
39+
echo "AWS_ACCOUNT_ID=759055860286" >> $GITHUB_ENV
40+
echo "AWS_S3_BUCKET=wallet-frontend-dev-759055860286-eu-west-1" >> $GITHUB_ENV
41+
42+
- name: Set staging ENV
43+
if: github.ref == 'refs/heads/staging'
44+
run: |
45+
echo "ENV=staging" >> $GITHUB_ENV
46+
echo "AWS_ACCOUNT_ID=924226199168" >> $GITHUB_ENV
47+
echo "AWS_S3_BUCKET=wallet-frontend-staging-924226199168-eu-west-1" >> $GITHUB_ENV
48+
49+
- name: Set demo ENV
50+
if: github.ref == 'refs/heads/demo'
51+
run: |
52+
echo "ENV=staging" >> $GITHUB_ENV
53+
echo "AWS_ACCOUNT_ID=924226199168" >> $GITHUB_ENV
54+
echo "AWS_S3_BUCKET=wallet-frontend-demo-924226199168-eu-west-1" >> $GITHUB_ENV
55+
56+
- name: Set prod ENV
57+
if: github.ref == 'refs/heads/prod'
58+
run: |
59+
echo "ENV=prod" >> $GITHUB_ENV
60+
echo "AWS_ACCOUNT_ID=255525589248" >> $GITHUB_ENV
61+
echo "AWS_S3_BUCKET=wallet-frontend-prod-255525589248-eu-west-1" >> $GITHUB_ENV
62+
63+
- name: Prepare .npmrc
64+
run: |
65+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" >> .npmrc
66+
cat .npmrc
67+
68+
- name: Install dependencies
69+
run: |
70+
cd frontend
71+
npm ci
72+
73+
- name: Building sources
74+
run: |
75+
cd frontend
76+
npm run build --if-present
77+
78+
- name: Configure AWS credentials
79+
uses: aws-actions/configure-aws-credentials@v4
80+
with:
81+
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/${{ env.PRODUCT }}-${{ env.APPLICATION }}-deployer-${{ env.AWS_DEFAULT_REGION }}-${{ env.ENV }}
82+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
83+
84+
- name: Deploy to S3
85+
run: |
86+
aws s3 sync ${{ env.BUILD_DIR }} s3://${{ env.AWS_S3_BUCKET }} --follow-symlinks --delete --no-progress
87+
88+
- name: Dynamically retreive the CloudFront Distribution Ids
89+
run: |
90+
cloudfrontdistids=$(aws cloudfront list-distributions | jq -r ".DistributionList.Items[].ARN")
91+
for dist in $cloudfrontdistids; do
92+
if [ $(aws cloudfront list-tags-for-resource --resource $dist --query "Tags.Items[?Key=='Application'].Value[]" --output text) == ${{ env.APPLICATION }} ] &&
93+
[ $(aws cloudfront list-tags-for-resource --resource $dist --query "Tags.Items[?Key=='Environment'].Value[]" --output text) == ${{ env.ENV }} ]; then
94+
CLOUDFRONT_DISTRIBUTION_IDS="$CLOUDFRONT_DISTRIBUTION_IDS ${dist##*/}"
95+
fi
96+
done
97+
echo "Cloudfront distributionids : $CLOUDFRONT_DISTRIBUTION_IDS"
98+
echo "CLOUDFRONT_DISTRIBUTION_IDS=$CLOUDFRONT_DISTRIBUTION_IDS" >> $GITHUB_ENV
99+
100+
- name: Invalidate CloudFront cache of distributions ${{ env.CLOUDFRONT_DISTRIBUTION_IDS }}
101+
run: |
102+
for dist in $CLOUDFRONT_DISTRIBUTION_IDS; do
103+
echo "Create invalidation for distribution-id $dist"
104+
aws cloudfront create-invalidation --distribution-id $dist --paths "/*"
105+
done

frontend/vite.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ export default defineConfig({
2323
protocol: "ws",
2424
},
2525
},
26+
build: {
27+
outDir: "build",
28+
},
2629
});

0 commit comments

Comments
 (0)