-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (85 loc) · 2.67 KB
/
deploy-dev.yml
File metadata and controls
102 lines (85 loc) · 2.67 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Deploy Documentation Site (Development)
on:
push:
branches:
- develop
concurrency:
group: deploy-dev-${{ github.ref }}
cancel-in-progress: true
env:
BUILD_DIR: "build"
AWS_REGION: ap-southeast-1
permissions:
contents: read
jobs:
build-docs-dev:
name: Build docs site (Dev)
runs-on: ubuntu-latest
permissions:
contents: read
env:
AWS_REGION: ap-southeast-1
S3_BUCKET: ${{ secrets.S3_BUCKET_DEV }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: develop
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci
- name: Build docs site
run: npm run build
- name: Upload docs artifact (Dev)
uses: actions/upload-artifact@v4
with:
name: docs-site-dev
path: ${{ env.BUILD_DIR }}
deploy-dev:
name: Deploy docs site to S3 (Dev)
needs: build-docs-dev
runs-on: ubuntu-latest
steps:
- name: Download docs artifact
uses: actions/download-artifact@v4
with:
name: docs-site-dev
path: ${{ env.BUILD_DIR }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ env.AWS_REGION }}
- name: Resolve target bucket
id: bucket
run: |
echo "bucket=${S3_BUCKET_DEV}" >> $GITHUB_OUTPUT
env:
S3_BUCKET_DEV: ${{ secrets.S3_BUCKET_DEV }}
- name: Sync static assets with long cache
run: |
aws s3 sync $BUILD_DIR s3://${{ steps.bucket.outputs.bucket }} \
--delete \
--exclude "*" \
--include "assets/*" \
--cache-control "public, max-age=31536000, immutable"
- name: Sync HTML and other assets with no-cache
run: |
aws s3 sync $BUILD_DIR s3://${{ steps.bucket.outputs.bucket }} \
--delete \
--exclude "assets/*" \
--cache-control "no-cache, no-store, must-revalidate"
- name: Invalidate CloudFront
env:
CLOUDFRONT_DISTRIBUTION_ID_DEV: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }}
if: ${{ env.CLOUDFRONT_DISTRIBUTION_ID_DEV != '' }}
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }} \
--paths "/*"