Repository navigation
49 lines (44 loc) · 1.87 KB
/
Copy pathdeploy-cdn.yml
File metadata and controls
49 lines (44 loc) · 1.87 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
name: Deploy to CDN (manual)
on:
workflow_dispatch:
inputs:
version:
description: 'Version to deploy (e.g. 1.1.0)'
required: true
type: string
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Validate version
run: |
if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version '${{ inputs.version }}' — expected semver like 1.1.0"
exit 1
fi
- name: Fetch package from npm
run: |
mkdir cdn
cd cdn
npm pack @devschile/chucao@${{ inputs.version }} --silent
tar -xzf devschile-chucao-*.tgz
- name: Deploy to CDN
run: |
aws --endpoint-url "$S3_ENDPOINT_URL" --region garage s3 sync cdn/package/dist/chucao "s3://$S3_BUCKET/chucao/${{ inputs.version }}/" \
--exclude "*.map" --exclude "fonts/*" \
--cache-control "public, max-age=31536000, immutable"
aws --endpoint-url "$S3_ENDPOINT_URL" --region garage s3 sync cdn/package/dist/chucao "s3://$S3_BUCKET/chucao/latest/" \
--exclude "*.map" --exclude "fonts/*" --delete \
--cache-control "public, max-age=3600"
aws --endpoint-url "$S3_ENDPOINT_URL" --region garage s3 rm "s3://$S3_BUCKET/chucao/latest/fonts/" --recursive
aws --endpoint-url "$S3_ENDPOINT_URL" --region garage s3 sync cdn/package/dist/chucao/fonts "s3://$S3_BUCKET/chucao/fonts/" \
--cache-control "public, max-age=31536000, immutable"
env:
S3_ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: garage
AWS_S3_ADDRESSING_STYLE: path