aboutsummaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2019-11-26 22:16:04 +0100
committerHans-Christoph Steiner <hans@eds.org>2019-12-10 16:06:53 +0100
commitfdfa3a5458d605d563637343dd58ac444dcf6dff (patch)
treeec80bd3e8bc54ad2fbdc5a53d769cc61f13b6f77 /.gitlab-ci.yml
parent9c86f54ba07355a968f982aed295e8b6597b4b89 (diff)
downloadtorspec-fdfa3a5458d605d563637343dd58ac444dcf6dff.tar.gz
torspec-fdfa3a5458d605d563637343dd58ac444dcf6dff.zip
build HTML GitLab Pages site with GitLab CI
This does a rough conversion to Markdown using regexps, then uses pandoc to convert the Markdown to HTML. An index.html is also generated to make it easy to find the various documents. This will create a site in any GitLab fork that has CI/CD and Pages setup, which is the default on gitlab.com.
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r--.gitlab-ci.yml33
1 files changed, 33 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..9211ec2
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,33 @@
+
+pages:
+ image: debian:buster
+ script:
+ - apt-get update
+ - apt-get -qy install --no-install-recommends pandoc
+ - test -d public || mkdir public
+ - printf '<!DOCTYPE html>\n\n<html><body><h1>%s</h1><ul>' $CI_PROJECT_PATH > public/index.html
+ - for f in *.txt; do
+ set -x;
+ name=`echo $f | sed s,\.txt$,,`;
+ md=${name}.md;
+ cat $f | sed --regexp-extended
+ -e '0,/^ +/{s/^ +/# /}'
+ -e 's/^ {1,3}([^ ])/\1/'
+ -e '/^[0-9]+\. +http/! s/^([0-9]+\. )/## \1/'
+ -e 's/^([0-9]+\.[0-9]+\. )/### \1/'
+ -e 's/^([0-9]+\.[0-9]+\.[0-9]+\. )/#### \1/'
+ -e 's/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\. )/##### \1/'
+ > $md;
+ printf "\n---\n\noriginal source\x3a [$f](https://gitweb.torproject.org/torspec.git/tree/$f)\n" >> $md;
+ title=`sed -En '0,/^# /s/^# (.*)/\1/p' $md`;
+ printf "<li><a href=\"${name}.html\"><tt>$name</tt>&colon; $title</a></li>" >> public/index.html;
+ pandoc --from=markdown $md --output=public/${name}.html;
+ mkdir public/$name;
+ cp public/${name}.html public/$name/index.html;
+ done
+ - printf '</ul></body></html>' >> public/index.html
+ artifacts:
+ paths:
+ - public
+ only:
+ - master