-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
215 lines (180 loc) · 6.03 KB
/
Taskfile.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
version: '3'
vars:
MODEL_REPO: [email protected]:AKSW/leipzig.dataweek.de-model.git
MODEL_DIR: .model
GRAPH_FILE: graph
GRAPH_IRI:
sh: cat {{.GRAPH_FILE}}.nt.graph || echo none
ICAL_REPO: [email protected]:AKSW/ical.dataweek.de.git
ICAL_DIR: .ical
ICAL_BRANCH: page-live
GIT_USER_NAME: DataWeek CMEM Update Bot 🤖
GIT_USER_EMAIL: [email protected]
GIT_COMMIT_MESSAGE: Update from CMEM
WORKING_DIRECTORY: '{{.github.workspace | default .PWD}}'
ID_UID:
sh: id -u
ID_GID:
sh: id -g
LANGUAGE: '{{.LANGUAGE | default "de"}}'
TARGET: '{{.TARGET | default "_site"}}'
TARGET_TMP_DE: '{{.TARGET_DE | default "_tmp/de"}}'
TARGET_TMP_EN: '{{.TARGET_DE | default "_tmp/en"}}'
TARGET_DE: '{{.TARGET_DE | default .TARGET}}'
TARGET_EN: '{{.TARGET_EN | default "_site/en"}}'
FLAVOUR: '{{.FLAVOUR | default "staging"}}'
BUILD_WATCH_FILES: find . -name '*' -not -path "./.git/*" -not -path "./.git" -not -path "./.jekyll-cache/*" -not -path "./.jekyll-cache" -not -path "./_tmp" -not -path "./_tmp/*" -not -path "./_site" -not -path "./_site/*"
tasks:
default:
summary: List all tasks
silent: true
cmds:
- task --list
ci:
desc: Build tasks for the CI
cmds:
- task: data:sync
- task: track:commit-and-push-data
- task: build
build:
desc: Build the page locally
deps:
- task: build:de
- task: build:en
cmds:
- test -d _site && rm -r _site || true
- mv {{.TARGET_TMP_DE}} {{.TARGET_DE}}
- mv {{.TARGET_TMP_EN}} {{.TARGET_EN}}
- task: ical:sync
- task: robots
release:
aliases: [deploy]
desc: Open a new pull request to merge develop to main
cmds:
- xdg-open https://github.com/AKSW/leipzig.dataweek.de/compare/main...develop?title=Deploy%20develop%20to%20main
watch:
desc: Serve the page and rebuild it on changes
deps:
- task: serve
- task: build:watch
cmds:
- echo "Terminate"
build:watch:
desc: Watch for changes in the directory and rebuild the page, should be combined with task serve in a second terminal
cmds:
- '{{.BUILD_WATCH_FILES}} | entr task build'
serve:
desc: Serve the locally built site
cmds:
- python -m http.server --directory {{.TARGET}}
build:de:
cmds:
- task: build:docker
vars:
LANGUAGE: de
TARGET: '{{.TARGET_TMP_DE}}'
build:en:
cmds:
- task: build:docker
vars:
LANGUAGE: en
TARGET: '{{.TARGET_TMP_EN}}'
build:docker:
vars:
JEKYLL_UID: '{{.JEKYLL_UID | default .ID_UID}}'
JEKYLL_GID: '{{.JEKYLL_GID | default .ID_GID}}'
JEKYLL_USER_ARG:
sh: '[ "$(docker info --format "{{`{{if .Host.Security.Rootless}}true{{end}}`}}")" = "true" ] || echo -u "{{.JEKYLL_UID}}:{{.JEKYLL_GID}}"'
JEKYLL_IMAGE: docker.io/aksw/jekyll-rdf:4.2.4
cmds:
- |
docker run --rm \
--workdir /github/workspace \
-v {{.WORKING_DIRECTORY}}:/github/workspace \
-e TZ=Europe/Berlin {{.JEKYLL_USER_ARG}} -e BUNDLE_PATH=.vendor -e JEKYLL_LANGUAGE={{.LANGUAGE}} \
{{.JEKYLL_IMAGE}} jekyll build -d {{.TARGET}}
data:sync:
desc: Synchronize the data in the CI
cmds:
- task: data:model-update
- task: data:get-graph
data:sync:local:
desc: Synchronize the data including local changes in a dev setup
deps:
- data:model-init
cmds:
- cd .model && task sync:local
- task: data:get-graph
data:get-graph:
cmds:
- cp {{.MODEL_DIR}}/{{.GRAPH_FILE}}.nt {{.GRAPH_FILE}}.nt
- cp {{.MODEL_DIR}}/{{.GRAPH_FILE}}.nt.graph {{.GRAPH_FILE}}.nt.graph
- echo {{.MODEL_REPO}} > {{.GRAPH_FILE}}.nt.source
- cd {{.MODEL_DIR}} && git rev-parse HEAD >> ../{{.GRAPH_FILE}}.nt.source
data:model-update:
deps:
- data:model-init
cmds:
- cd {{.MODEL_DIR}} && git pull
data:model-init:
cmds:
- git clone {{.MODEL_REPO}} {{.MODEL_DIR}}
status:
- test -d {{.MODEL_DIR}}
ical:update:
deps:
- ical:init
cmds:
- cd {{.ICAL_DIR}} && git pull
ical:init:
cmds:
- git clone -b {{.ICAL_BRANCH}} {{.ICAL_REPO}} {{.ICAL_DIR}}
status:
- test -d {{.ICAL_DIR}}
ical:merge:
desc: Merge the ical feeds into the site directory
cmds:
- cp -r {{.ICAL_DIR}}/* _site/
- cp -r {{.ICAL_DIR}}/* _site/en/
ical:sync:
desc: Synchronize the ical feeds
cmds:
- task: ical:update
- task: ical:merge
pictures:scale:
deps:
- task: pictures:scale:preconditions
vars:
PICTURE_SIZE: 480
SOURCE_DIR: resources/images/people_raw
TARGET_DIR: resources/images/people
cmds:
- for i in {{.SOURCE_DIR}}/* ; do mkdir -p {{.TARGET_DIR}}; test -f "{{.TARGET_DIR}}/$(basename $i)" && echo "skip {{.TARGET_DIR}}/$(basename $i)" || smartcrop --width {{.PICTURE_SIZE}} --height {{.PICTURE_SIZE}} -i "$i" -o "{{.TARGET_DIR}}/$(basename $i)"; done
- task: track:commit-and-push-pictures
vars:
TARGET_DIR: '{{.TARGET_DIR}}'
pictures:scale:preconditions:
cmds:
- pip install opencv-python
- pip install git+https://github.com/epixelic/python-smart-crop
status:
- '[ ${INSTALL_PICTURES_SCALE_PRECONDITIONS} != "True" ]'
pictures:scale:leipzig:
cmds:
- sizes="480 800 1200 1600 1980"; for i in $sizes; do convert resources/images/Leipzig.jpg -resize ${i}x resources/images/Leipzig_${i}.jpg; done
robots:
desc: Put the correct robots.txt into the _site folder
cmds:
- cp robots-{{.FLAVOUR}}.txt _site/robots.txt
track:commit-and-push-pictures:
- git add {{.TARGET_DIR}}
- task: track:commit-and-push
vars:
GIT_COMMIT_MESSAGE: Update Pictures
track:commit-and-push-data:
- git add {{.GRAPH_FILE}}.nt {{.GRAPH_FILE}}.nt.graph {{.GRAPH_FILE}}.nt.source
- task: track:commit-and-push
track:commit-and-push:
cmds:
- git -c user.name="{{.GIT_USER_NAME}}" -c user.email="{{.GIT_USER_EMAIL}}" commit -m "{{.GIT_COMMIT_MESSAGE}}" || echo ""
- git push || echo ""