-
Notifications
You must be signed in to change notification settings - Fork 1.2k
77 lines (64 loc) · 2.23 KB
/
cache-images.yaml
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
name: Update Hugo image cache
on:
push:
branches:
- develop
env:
repo_name: docs
repo_owner: linode
hugo_image_cache_name: hugo-generated-images
hugo_image_cache_path: /home/runner/work/docs/docs/docs-repo/resources/_gen/images/
jobs:
cache-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: docs-repo
- name: Print current docs repo branch/ref/commit
working-directory: ./docs-repo
run: |
git status
git log -1
- name: List contents of images dir
continue-on-error: true
run: ls -al ${{ env.hugo_image_cache_path }}
- name: Cache images dir
uses: actions/cache@v2
with:
path: ${{ env.hugo_image_cache_path }}
key: ${{ env.hugo_image_cache_name }}-${{ github.run_id }}
restore-keys: |
${{ env.hugo_image_cache_name }}
- name: List contents of images dir
continue-on-error: true
run: ls -al ${{ env.hugo_image_cache_path }}
- name: Install dependencies (Node)
working-directory: ./docs-repo
run: npm ci
- name: Set up Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.116.1'
- name: Build Hugo
working-directory: ./docs-repo
run: hugo --gc
- name: List existing Hugo image caches
run: |
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ env.repo_owner }}/${{ env.repo_name }}/actions/caches?key=${{ env.hugo_image_cache_name }} \
-o cache-list.json
echo "The following caches will be deleted:"
cat cache-list.json
- name: Delete existing Hugo image caches
run: |
for id in $(jq '.actions_caches[].id' cache-list.json); do
echo "Deleting cache with id $id"
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ env.repo_owner }}/${{ env.repo_name }}/actions/caches/$id
done