-
-
Notifications
You must be signed in to change notification settings - Fork 9
165 lines (143 loc) · 5.02 KB
/
gh-pages.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#*******************************************************************************
# gh-pages.yml
#
# Github Workflow to deploy Interlisp.org.
#
# Interlisp.org is a Hugo based static website that contains a
# detailed bibliography maintained using Zotero (https://www.zotero.org/groups/2914042/interlispwww.zotero.org/).
#
# This workflow consists of two jobs, one to ensure that we have the latest
# version of the Zotero bibliography and a second job to deploy the website.
#
# The workflow is executed either on a push or via scheduled run times. When
# started at a scheduled run time we only do a deploy if the cached bibliography
# is no longer current. On a push, we always verifty the the current
# bibliography is loaded and deploy a new version of the website.
#
# 2023-10-20 Bill Stumbo
#
# Copyright 2023 by Interlisp.org
#
# ******************************************************************************
name: github pages
on:
push:
branches:
- main # Set a branch to deploy
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
defaults:
run:
shell: bash
env:
# ----------------------------------------------------------------------------
# Specify the deployment environment: staging or production
HUGO_ENVIRONMENT: production
HUGO_VERSION: 0.133.1
jobs:
# ----------------------------------------------------------------------------
# Use the Zotero REST API to get the current version of the Zotero Bibliography
# Compare against a cached version of the bibliography.
#
check:
outputs:
zoteroVersion: ${{ fromJson(steps.zoteroVersion.outputs.headers).last-modified-version }}
cacheHit: ${{ steps.cache-zotero-bib.outputs.cache-hit }}
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Get Zotero Version Information
id: zoteroVersion
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.zotero.org/groups/2914042/items?format=versions"
method: "GET"
- name: Cache Zotero Bibliography
id: cache-zotero-bib
uses: actions/cache@v4
env:
cache-name: cache-zotero_bib
with:
path: ~/data
key: ${{ fromJson(steps.zoteroVersion.outputs.headers).last-modified-version }}
restore-keys: |
${{ fromJson(steps.zoteroVersion.outputs.headers).last-modified-version }}
# ----------------------------------------------------------------------------
# Build the website. This job is conditional, we will always run it on a
# push or if on a scheduled run the cache was determined to be out of date.
#
build:
needs: check
runs-on: ubuntu-latest
if: github.event_name == 'push' || needs.check.outputs.cacheHit != 'true'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Cache Zotero Bibliography
id: cache-zotero-bib
uses: actions/cache@v4
env:
cache-name: cache-zotero_bib
with:
path: ~/data
key: ${{ needs.check.outputs.zoteroVersion }}
restore-keys: |
${{ needs.check.outputs.zoteroVersion }}
- name: Install Bibliography
env:
CACHE_HIT: ${{ steps.cache-zotero-bib.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" == 'true' ]]; then
echo "Use Cache"
sudo cp --recursive ~/data ${GITHUB_WORKSPACE}/static
ls -la ${GITHUB_WORKSPACE}/static/data
else
echo "Retrieve bibliography"
cd scripts
chmod +x ./update_bibliography.sh
./update_bibliography.sh
sudo cp --recursive ${GITHUB_WORKSPACE}/static/data ~/data
fi
# Install Hugo Extended
#
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- run: npm install -g autoprefixer --save-dev
- run: npm install -g postcss-cli --save-dev
- run: npm install --verbose
- name: Build
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
TZ: America/New York
run: hugo --cleanDestinationDir -e $HUGO_ENVIRONMENT
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4