-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (171 loc) · 6.2 KB
/
build_course.yaml
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
name: Build Course
on:
workflow_dispatch:
inputs:
course_code:
description: Code of the course to build
required: true
type: string
course_description:
description: Description of the course to build
required: true
type: string
concurrency: dscourses-writer
jobs:
build_course:
runs-on: ubuntu-latest
steps:
- id: course-code
run: course_code=${{ inputs.course_code }} ; echo lowercase=${course_code,,} >> "$GITHUB_OUTPUT"
- name: Checkout ${{ github.repository }} repository
uses: actions/checkout@v4
- name: Get active branch
id: active-branch
run: |
course_code="${{ steps.course-code.outputs.lowercase }}"
echo active-branch="$(jq -r "if has(\"$course_code\") then .$course_code else \"\" end" ./branches.json)" >> "$GITHUB_OUTPUT"
- name: Checkout ${{ github.repository_owner }}/${{ inputs.course_code }} repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/${{ inputs.course_code }}
path: docs
ref: ${{ steps.active-branch.outputs.active-branch }}
token: ${{ secrets.PAT_TOKEN }}
- name: Checkout ${{ github.repository_owner }}/dscourses repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/dscourses
path: dscourses
token: ${{ secrets.PAT_TOKEN }}
- name: Get current year
id: current-year
run: echo "current-year=$(date +%Y)" >> "$GITHUB_OUTPUT"
- name: Generate PDF name
id: pdf-name
run: |
shopt -s extglob
result='${{ inputs.course_description }}' ; result="${result,,}" ; echo result="${result//+([[:space:]])/-}.pdf" >> "$GITHUB_OUTPUT"
- name: Generate MkDocs Configuration
run: |
cat > mkdocs.yml <<EOF
site_name: '${{ inputs.course_code }}'
site_url: https://www.deso.tech
site_description: '${{ inputs.course_description }}'
site_author: Desotech TM
copyright: Copyright © 2016 - ${{ steps.current-year.outputs.current-year }} Desotech
use_directory_urls: false
theme:
name: null
custom_dir: material
highlightjs: true
hljs_languages:
- yaml
features:
- header.autohide
- toc.integrate
include_sidebar: true
static_templates:
- 404.html
include_search_page: false
search_index_only: true
language: en
feature:
tabs: false
palette:
primary: grey
accent: grey
font:
text: Roboto
code: Roboto Mono
favicon: assets/favicon.ico
logo: assets/desotech-cubo-small.png
markdown_extensions:
- admonition
- abbr
- attr_list
- def_list
- footnotes
- meta
- toc:
permalink: true
- pymdownx.arithmatex:
generic: true
- pymdownx.betterem:
smart_enable: all
- pymdownx.caret
- pymdownx.critic
- pymdownx.details
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.keys
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.snippets:
check_paths: true
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- pymdownx.tabbed
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde
plugins:
- minify:
minify_html: false
- codeinclude
- awesome-pages
- img2fig
- exclude:
glob:
- mkdocs.yml
- '*.incomplete'
- 'drafts/*'
- with-pdf:
author: Desotech srl
copyright: ${{ steps.year.outputs.year }} Desotech srl or its affiliates. All rights reserved.
cover_logo: assets/logopdf.png
cover: true
back_cover: true
cover_subtitle: '${{ inputs.course_description }}'
ordered_chapter_level: 2
render_js: true
headless_chrome_path: chrome
output_path: 'pdf/${{ steps.pdf-name.outputs.result }}'
debug_html: false
show_anchors: false
verbose: false
EOF
- name: Set Up Chromium
uses: browser-actions/setup-chrome@latest
with:
chrome-version: '848897'
- name: Install Python Dependencies
run: |
set -eu
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Link assets folder
run: ln -fs ../assets docs/assets
- name: Build Site
run: mkdocs build
- name: Add Favicon
run: cp -- favicon.ico site/favicon.ico
- name: Copy Output Files
run: rsync -r --exclude password.txt --exclude .htpasswd --delete site/ dscourses/${{ steps.course-code.outputs.lowercase }}
- name: Push Changes
run: |
git -C dscourses config --local user.name 'GitHub Actions'
git -C dscourses config --local user.email [email protected]
git -C dscourses add -A
if git -C dscourses commit -m 'Update ${{ inputs.course_code }}'
then
retries=0
until git -C dscourses push || [ "$retries" -gt 10 ] ; do sleep 5 ; git -C dscourses pull --rebase ; ((retries++)) ; done
else
echo 'Nothing to commit. The site is already up-to-date.'
fi