-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (170 loc) · 7.08 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Publish on GitHub pages
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '30 23 1 * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
HUGO_VERSION: 0.133.0
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
# - name: Maximize build space
# uses: easimon/maximize-build-space@master
# with:
# root-reserve-mb: 4096
# temp-reserve-mb: 1096
# remove-android: 'true'
# remove-haskell: 'true'
# remove-codeql: 'true'
# remove-dotnet: 'true'
- name: Free some disk space
run: |
sudo rm -rf /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL /usr/local/graalvm/ /usr/local/share/powershell /usr/local/lib/android /usr/local/.ghcup/ /usr/share/dotnet/ /opt/microsoft /usr/local/aws-* /usr/share/miniconda /opt/az /usr/share/kotlinc /usr/share/man /usr/share/sbt /usr/local/julia* /usr/share/az* /usr/share/apache-maven* /usr/share/gradle* /usr/share/swift
df -h
- uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true OR recursive)
- name: Login to GitHub Packages Docker Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
logout: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install required dependencies
run: |
./scripts/github-setup.sh
- name: Setup deploy dependencies
env:
DEPLOY_SSH_IDENTITY: ${{ secrets.DEPLOY_SSH_IDENTITY }}
run: |
mkdir -p ~/.ssh && echo "$DEPLOY_SSH_IDENTITY" >> ~/.ssh/known_hosts
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
- name: Generate Files
env:
SKIP_IIIF: yes
SKIP_PDF: yes
NODE_OPTIONS: --openssl-legacy-provider
run: |
./scripts/setup.sh
yarn run clean-build
# - name: Create PDF
# run: |
# python themes/projektemacher-base/scripts/pdf.py
# - name: Create IIIF derivates and upload
# env:
# DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
# DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
# SSHPASS: ${{ secrets.DEPLOY_PASS }}
# DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
# run: docker run -e CHOWN_UID=${UID} -e DEPLOY_SERVER="$DEPLOY_SERVER" -e DEPLOY_USER="$DEPLOY_USER" -e SSHPASS="$SSHPASS" -e DEPLOY_PATH="$DEPLOY_PATH" -e URL_PREFIX="https://static.projektemacher.org/kinderbuecher/" -v ${PWD}:${PWD} ghcr.io/cmahnke/iiif-action:latest-jxl-uploader sh -c "cd ${PWD} && ./scripts/iiif-upload.sh"
- name: Create IIIF derivates
run: |
echo "Running as ${UID}"
docker run -e CHOWN_UID=${UID} -e URL_PREFIX="https://static.projektemacher.org/kinderbuecher/" -v ${PWD}:${PWD} ghcr.io/cmahnke/iiif-action:latest-jxl-uploader sh -c "cd ${PWD} && ./scripts/iiif.sh"
- name: Create PDF
run: |
python themes/projektemacher-base/scripts/pdf.py
- name: Upload
env:
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
SSHPASS: ${{ secrets.DEPLOY_PASS }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
run: |
cd content
find post -name info.json -exec dirname {} \; > files.lst
find post -name "*.pdf" -exec echo "{}" \; >> files.lst
cat files.lst | xargs chmod 775
# Add this to rsync '--info=progress2' to get a complete progess status
sshpass -e rsync -a --size-only --delete --relative $(cat files.lst) $DEPLOY_USER@$DEPLOY_SERVER:$DEPLOY_PATH/kinderbuecher/
rm -f files.lst
- name: Cleanup
run: |
find content/post/ -name info.json -exec dirname {} \; | xargs -I {} find {} -mindepth 1 -type d -not -path '*/full*' | xargs rm -fr
find content/post/ -name '*.pdf' -exec rm -r {} \;
df -h
# - name: Create and upload PDF
# env:
# DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
# DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
# SSHPASS: ${{ secrets.DEPLOY_PASS }}
# DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
# run: |
# python themes/projektemacher-base/scripts/pdf.py
# cd content
# find post -name "*.pdf" -exec echo "{}" \; > files.lst
# cat files.lst | xargs chmod 775
# sshpass -e rsync -aP --size-only --delete --exclude=*.json --exclude=*.jpg --relative $(cat files.lst) $DEPLOY_USER@$DEPLOY_SERVER:$DEPLOY_PATH/kinderbuecher/
# rm -f files.lst
# cd ..
# find content/post/ -name '*.pdf' -exec rm -r {} \;
#
# - name: Remove PDF
# run: |
# find content/post/ -name '*.pdf' -exec rm -r {} \;
# - name: Create IIIF derivates
# run: docker run -e CHOWN_UID=${UID} -e URL_PREFIX="https://static.projektemacher.org/kinderbuecher/" -v ${PWD}:${PWD} ghcr.io/cmahnke/iiif-action:latest sh -c "cd ${PWD} && ./scripts/iiif.sh"
#
# - name: IIIF directory upload and cleanup
# env:
# DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
# DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
# SSHPASS: ${{ secrets.DEPLOY_PASS }}
# DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
# run: |
# cd content
# find post -name info.json -exec dirname {} \; > files.lst
# cat files.lst | xargs chmod 775
# sshpass -e rsync -aP --size-only --delete --relative $(cat files.lst) $DEPLOY_USER@$DEPLOY_SERVER:$DEPLOY_PATH/kinderbuecher/
# rm -f files.lst
# cd ..
# find content/post/ -name info.json -exec dirname {} \; | xargs rm -r
- name: Setup Hugo
uses: peaceiris/[email protected]
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: Generate stats
run: |
./themes/projektemacher-base/scripts/stat.sh
- name: Build Hugo site
run: hugo --printI18nWarnings --printUnusedTemplates --logLevel=debug
- name: Cleanup Build
run: |
find docs -type f -size +5M -name '*.jpg' -print -exec rm {} \;
find docs -type f -name '*.jxl' -print -exec rm {} \;
find docs -type f -name 'vips-properties.xml' -print -exec rm {} \;
find docs -type f -path '*/full/full/0/default.jpg' -print -exec rm {} \;
- name: Validate JSON
env:
OSTYPE: linux
run: |
yarn run validate
- name: Cleanup disk
run: |
df -h
docker rmi -f ghcr.io/cmahnke/iiif-action:latest-jxl-uploader
rm -rf node_modules
rm -rf content
df -h
- name: Deploy site
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
force_orphan: true