-
-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (77 loc) · 3.1 KB
/
deploy.yml
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
name: Publish site
on:
push:
branches:
- main
# limit to one concurrent run per PR/branch,
# and cancel any previous runs still going
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache image files
uses: actions/cache@v3
with:
path: public/img
key: ${{ runner.os }}-images-${{ hashFiles('src/**/*.png', 'src/**/*.jpe?g', 'src/**/*.gif', 'src/**/*.svg') }}
restore-keys: ${{ runner.os }}-images-
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- run: npm install
- run: npm run-script build
env:
CI: true
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: kheiakiyama/install-azcopy-action@d0c8a54798ecf011ec2219ea553196e19a16e7f8
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Upload to blob storage
run: azcopy sync public 'https://waystoplay.blob.core.windows.net/$web' --delete-destination=true --compare-hash=MD5 --put-md5=true
- name: Set cache-control on fonts/images
run: |
noHeaderFilter='.[] | select(.properties.contentSettings.cacheControl == null) | .name'
export AZURE_STORAGE_AUTH_MODE=login
export AZURE_STORAGE_ACCOUNT=waystoplay
echo CSS - 1 week
blobs=$(az storage blob list --container-name '$web' --prefix css/ | jq -r "$noHeaderFilter")
for blob in $blobs; do
az storage blob update --container-name '$web' --name "$blob" --content-cache 'max-age=604800'
done
echo fonts - 6 months
blobs=$(az storage blob list --container-name '$web' --prefix fonts/ | jq -r "$noHeaderFilter")
for blob in $blobs; do
az storage blob update --container-name '$web' --name "$blob" --content-cache 'max-age=15768000'
done
echo images - 6 months
blobs=$(az storage blob list --container-name '$web' --prefix img/ | jq -r "$noHeaderFilter")
for blob in $blobs; do
az storage blob update --container-name '$web' --name "$blob" --content-cache 'max-age=15768000'
done
echo small-images - 6 months
blobs=$(az storage blob list --container-name '$web' --prefix small-images/ | jq -r "$noHeaderFilter")
for blob in $blobs; do
az storage blob update --container-name '$web' --name "$blob" --content-cache 'max-age=15768000'
done
echo audio - 6 months
blobs=$(az storage blob list --container-name '$web' --prefix audio/ | jq -r "$noHeaderFilter")
for blob in $blobs; do
az storage blob update --container-name '$web' --name "$blob" --content-cache 'max-age=15768000'
done
- name: Purge CDN
uses: azure/CLI@v1
with:
inlineScript: |
az cdn endpoint purge -g ways-to-play --profile-name ways-to-play-cdn -n waystoplay --content-paths '/*' --no-wait
- name: logout
run: az logout
if: always()