Skip to content

Commit 933266c

Browse files
Consolatisjohanmalm
authored andcommitted
CI: Add auto deployment on push, manual, webhook trigger
- push (e.g. accepting a PR) - manually via Actions tab - potentially in the future via webhook triggered by labwc
1 parent 27db170 commit 933266c

21 files changed

+85
-2641
lines changed

.github/workflows/deploy.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Ref: https://github.com/actions/starter-workflows/tree/main/pages
2+
# Ref: https://stackoverflow.com/questions/65370859/github-action-trigger-on-another-repo-update-push-pull-request/65514259#65514259
3+
4+
on:
5+
# When accepting PRs
6+
push:
7+
branches:
8+
- 'main'
9+
10+
# Allow running workflow manually
11+
workflow_dispatch:
12+
13+
# Allow labwc main repo to trigger the action
14+
repository_dispatch:
15+
types:
16+
- rebuild
17+
18+
jobs:
19+
20+
build:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Prepare
25+
run: sudo apt update && sudo apt install -y scdoc pandoc
26+
27+
- name: Checkout labwc.github.io
28+
uses: actions/checkout@v3
29+
30+
- name: Checkout labwc
31+
uses: actions/checkout@v3
32+
with:
33+
repository: 'labwc/labwc'
34+
path: 'labwc'
35+
36+
- name: Build page
37+
run: ./build-site
38+
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v1
41+
with:
42+
path: 'deploy'
43+
44+
deploy:
45+
needs: build
46+
47+
permissions:
48+
pages: write
49+
id-token: write
50+
51+
environment:
52+
name: github-pages
53+
url: ${{ steps.deployment.outputs.page_url }}
54+
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Deploy
58+
id: deployment
59+
uses: actions/deploy-pages@v1

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
labwc/
2+
deploy/*.html

build-site

+21-27
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,40 @@
11
#!/usr/bin/env bash
2-
#
3-
# This script depends on pandoc
4-
#
52

6-
: ${LABWC_DOC_DIR:=../labwc/build/docs}
73

8-
die () {
9-
printf 'fatal: %b\n' "$@" >&2
10-
exit 1
11-
}
4+
: ${DEPLOY_DIR:=deploy}
125

136
build_src_pages () {
14-
template="$(<"src/template.html")"
157
for md in src/*.md; do
16-
filename=${md##*/}
17-
html="${filename/%.md/.html}"
18-
[[ $html -ot $md ]] || continue
19-
printf '%s\n' " GEN ${html}"
20-
printf '%b' "${template/'{{content}}'/$(pandoc --from=markdown+footnotes "$md")}" >"${html}"
8+
html=${md##*/}
9+
html="${DEPLOY_DIR}/${html/%.md/.html}"
10+
echo "Converting $md to $html"
11+
12+
cat src/template_pre.html > "$html"
13+
pandoc --from=markdown+footnotes "$md" >> "$html"
14+
cat src/template_post.html >> "$html"
2115
done
2216
}
2317

2418
build_man_pages () {
25-
if ! [[ -d "$LABWC_DOC_DIR" ]]; then
26-
printf 'warn: %b\n' "Need labwc next to labwc.github.io with man pages built" >&2
27-
return
28-
fi
29-
template="$(sed -e 's/sans-serif;/monospace;/' src/template.html)"
30-
for scd in "$LABWC_DOC_DIR"/*; do
31-
filename=${scd##*/}
32-
html=$(basename ${scd}).html
33-
[[ $html -ot $scd ]] || continue
34-
printf '%s\n' " GEN ${html}"
35-
printf '%b' "${template/'{{content}}'/$(pandoc --from man "$scd")}" >"${html}"
36-
./fix-bullet-formatting.py "${html}"
19+
test -d labwc || git clone --branch master --depth 1 https://github.com/labwc/labwc labwc
20+
21+
for scd in labwc/docs/*.scd; do
22+
html=${scd##*/}
23+
html="${DEPLOY_DIR}/${html/%.scd/.html}"
24+
echo "Converting $scd to $html"
25+
26+
sed 's/sans-serif;/monospace;/' src/template_pre.html > "$html"
27+
scdoc < "$scd" | pandoc --from man >> "$html"
28+
cat src/template_post.html >> "$html"
29+
./fix-bullet-formatting.py "$html"
3730
done
3831
}
3932

4033
main () {
34+
mkdir -p "$DEPLOY_DIR"
35+
4136
build_src_pages
4237
build_man_pages
4338
}
4439

4540
main "$@"
46-

img/labwc.png deploy/img/labwc.png

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

diagrams-theme.html

-135
This file was deleted.

0 commit comments

Comments
 (0)