File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CD (Deploy to S3 + CloudFront)
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ deploy :
10+ name : Build & Deploy
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+
17+ - name : Setup Node.js
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : 20
21+ cache : yarn
22+
23+ - name : Install dependencies
24+ run : yarn install --frozen-lockfile
25+
26+ - name : Build project
27+ run : yarn build
28+
29+ - name : Configure AWS credentials
30+ uses : aws-actions/configure-aws-credentials@v4
31+ with :
32+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
33+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
34+ aws-region : ${{ secrets.AWS_REGION }}
35+
36+ - name : Upload to S3
37+ run : |
38+ aws s3 sync dist s3://${{ secrets.S3_BUCKET_NAME }} \
39+ --delete \
40+ --cache-control "public,max-age=31536000,immutable" \
41+ --exclude "index.html"
42+
43+ - name : Upload index.html with no-cache
44+ run : |
45+ aws s3 cp dist/index.html s3://${{ secrets.S3_BUCKET_NAME }}/index.html \
46+ --cache-control "no-cache,no-store,must-revalidate"
47+
48+ - name : Invalidate CloudFront cache
49+ run : |
50+ aws cloudfront create-invalidation \
51+ --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
52+ --paths "/*"
You can’t perform that action at this time.
0 commit comments