-
-
Notifications
You must be signed in to change notification settings - Fork 10
130 lines (117 loc) · 4.28 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
#*******************************************************************************
# 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 * * *"
env:
# ----------------------------------------------------------------------------
# Specify the deployment environment: staging or production
hugoEnvironment: production
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 }}
# ----------------------------------------------------------------------------
# Deploy 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.
#
deploy:
needs: check
runs-on: ubuntu-latest
if: github.event_name == 'push' || needs.check.outputs.cacheHit != 'true'
steps:
- uses: actions/checkout@v4
- 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
shell: bash
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.127.0'
extended: true
- 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
run: hugo -e $hugoEnvironment
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public