1
+ # *******************************************************************************
2
+ # gh-pages.yml
3
+ #
4
+ # Github Workflow to deploy Interlisp.org.
5
+ #
6
+ # Interlisp.org is a Hugo based static website that contains a
7
+ # detailed bibliography maintained using Zotero (https://www.zotero.org/groups/2914042/interlispwww.zotero.org/).
8
+ #
9
+ # This workflow consists of two jobs, one to ensure that we have the latest
10
+ # version of the Zotero bibliography and a second job to deploy the website.
11
+ #
12
+ # The workflow is executed either on a push or via scheduled run times. When
13
+ # started at a scheduled run time we only do a deploy if the cached bibliography
14
+ # is no longer current. On a push, we always verifty the the current
15
+ # bibliography is loaded and deploy a new version of the website.
16
+ #
17
+ # 2023-10-20 Bill Stumbo
18
+ #
19
+ # Copyright 2023 by Interlisp.org
20
+ #
21
+ # ******************************************************************************
1
22
name : github pages
2
23
3
24
on :
4
25
push :
5
26
branches :
6
27
- main # Set a branch to deploy
7
- pull_request :
28
+
29
+ schedule :
30
+ - cron : " 0 3 * * *"
31
+
32
+ workflow_dispatch :
33
+
34
+ permissions :
35
+ contents : read
36
+ pages : write
37
+ id-token : write
38
+
39
+ defaults :
40
+ run :
41
+ shell : bash
42
+
43
+ env :
44
+ # ----------------------------------------------------------------------------
45
+ # Specify the deployment environment: staging or production
46
+ HUGO_ENVIRONMENT : production
47
+ HUGO_VERSION : 0.133.1
8
48
9
49
jobs :
10
- deploy :
11
- runs-on : ubuntu-22.04
50
+ # ----------------------------------------------------------------------------
51
+ # Use the Zotero REST API to get the current version of the Zotero Bibliography
52
+ # Compare against a cached version of the bibliography.
53
+ #
54
+ check :
55
+ outputs :
56
+ zoteroVersion : ${{ fromJson(steps.zoteroVersion.outputs.headers).last-modified-version }}
57
+ cacheHit : ${{ steps.cache-zotero-bib.outputs.cache-hit }}
58
+
59
+ runs-on : ubuntu-latest
12
60
concurrency :
13
61
group : ${{ github.workflow }}-${{ github.ref }}
14
62
steps :
15
- - uses : actions/checkout@v3
16
63
17
- - name : Setup Hugo
18
- uses : peaceiris/actions-hugo@v2
64
+ - name : Get Zotero Version Information
65
+ id : zoteroVersion
66
+ uses : fjogeleit/http-request-action@v1
67
+ with :
68
+ url : " https://api.zotero.org/groups/2914042/items?format=versions"
69
+ method : " GET"
70
+
71
+ - name : Cache Zotero Bibliography
72
+ id : cache-zotero-bib
73
+ uses : actions/cache@v4
74
+ env :
75
+ cache-name : cache-zotero_bib
76
+ with :
77
+ path : ~/data
78
+ key : ${{ fromJson(steps.zoteroVersion.outputs.headers).last-modified-version }}
79
+ restore-keys : |
80
+ ${{ fromJson(steps.zoteroVersion.outputs.headers).last-modified-version }}
81
+
82
+ # ----------------------------------------------------------------------------
83
+ # Build the website. This job is conditional, we will always run it on a
84
+ # push or if on a scheduled run the cache was determined to be out of date.
85
+ #
86
+ build :
87
+ needs : check
88
+ runs-on : ubuntu-latest
89
+ if : github.event_name == 'push' || needs.check.outputs.cacheHit != 'true'
90
+ steps :
91
+ - uses : actions/checkout@v4
19
92
with :
20
- hugo-version : ' latest'
21
- extended : true
93
+ submodules : recursive
94
+ fetch-depth : 0
95
+
96
+ - name : Cache Zotero Bibliography
97
+ id : cache-zotero-bib
98
+ uses : actions/cache@v4
99
+ env :
100
+ cache-name : cache-zotero_bib
101
+ with :
102
+ path : ~/data
103
+ key : ${{ needs.check.outputs.zoteroVersion }}
104
+ restore-keys : |
105
+ ${{ needs.check.outputs.zoteroVersion }}
106
+
107
+ - name : Install Bibliography
108
+ env :
109
+ CACHE_HIT : ${{ steps.cache-zotero-bib.outputs.cache-hit }}
110
+ run : |
111
+ if [[ "$CACHE_HIT" == 'true' ]]; then
112
+ echo "Use Cache"
113
+ sudo cp --recursive ~/data ${GITHUB_WORKSPACE}/static
114
+ ls -la ${GITHUB_WORKSPACE}/static/data
115
+ else
116
+ echo "Retrieve bibliography"
117
+ cd scripts
118
+ chmod +x ./update_bibliography.sh
119
+ ./update_bibliography.sh
120
+ sudo cp --recursive ${GITHUB_WORKSPACE}/static/data ~/data
121
+ fi
122
+
123
+ # Install Hugo Extended
124
+ #
125
+ - name : Install Hugo CLI
126
+ run : |
127
+ wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
128
+ && sudo dpkg -i ${{ runner.temp }}/hugo.deb
129
+
130
+ - name : Setup Pages
131
+ id : pages
132
+ uses : actions/configure-pages@v5
22
133
23
134
- name : Setup Node
24
- uses : actions/setup-node@v3
135
+ uses : actions/setup-node@v4
25
136
with :
26
137
node-version : 18
27
138
@@ -30,11 +141,25 @@ jobs:
30
141
- run : npm install --verbose
31
142
32
143
- name : Build
33
- run : hugo
34
-
35
- - name : Deploy
36
- uses : peaceiris/actions-gh-pages@v3
37
- if : github.ref == 'refs/heads/main'
144
+ env :
145
+ HUGO_CACHEDIR : ${{ runner.temp }}/hugo_cache
146
+ TZ : America/New York
147
+ run : hugo --cleanDestinationDir -e $HUGO_ENVIRONMENT
148
+
149
+ - name : Upload artifact
150
+ uses : actions/upload-pages-artifact@v3
38
151
with :
39
- github_token : ${{ secrets.GITHUB_TOKEN }}
40
- publish_dir : ./public
152
+ path : ./public
153
+
154
+ deploy :
155
+ environment :
156
+ name : github-pages
157
+ url : ${{ steps.deployment.outputs.page_url }}
158
+ runs-on : ubuntu-latest
159
+ needs : build
160
+
161
+ steps :
162
+ - name : Deploy to GitHub Pages
163
+ id : deployment
164
+ uses : actions/deploy-pages@v4
165
+
0 commit comments