-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (66 loc) · 2.21 KB
/
deploy.yml
File metadata and controls
79 lines (66 loc) · 2.21 KB
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
name: Deploy Docusaurus to S3 + CloudFront
on:
# push:
# branches:
# - main
# paths:
# - 'docs-site/**'
# - '.github/workflows/deploy.yml'
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'docs-site/package-lock.json'
- name: Install dependencies
working-directory: docs-site
run: npm ci
- name: Build Docusaurus site
working-directory: docs-site
run: npm run build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ap-northeast-1
- name: Sync to S3
working-directory: docs-site/build
run: |
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET }} \
--delete \
--cache-control "public, max-age=31536000, immutable" \
--exclude "*.html" \
--exclude "*.xml" \
--exclude "*.json"
# HTML files with no cache
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET }} \
--cache-control "public, max-age=0, must-revalidate" \
--content-type "text/html" \
--exclude "*" \
--include "*.html"
# XML and JSON files with short cache
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET }} \
--cache-control "public, max-age=3600" \
--exclude "*" \
--include "*.xml" \
--include "*.json"
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"
- name: Deployment summary
run: |
echo " Deployment completed successfully!"
echo "=� S3 Bucket: ${{ secrets.AWS_S3_BUCKET }}"
echo "< CloudFront Distribution: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }}"