Add Github Action to produce HTML manual page
[abduco.git] / .github / workflows / man.yml
blob9c3b02058bb5076a5920340a5995197b53c7988b
1 name: Manual
3 env:
4   PROJECT: abduco
6 on:
7   push:
8     paths:
9     - '*.1'
11 jobs:
12   man:
13     runs-on: ubuntu-latest
14     steps:
16     - name: Checkout
17       uses: actions/checkout@v2
19     - name: Dependency
20       run: sudo apt install mandoc
22     - name: Manual generation
23       run: |
24         mkdir man
25         sed -e "s/VERSION/$(git describe --always)/" ${PROJECT}.1 | \
26           mandoc -W warning -T utf8 -T html -O man=%N.%S.html -O style=mandoc.css 1> \
27           "man/${PROJECT}.1.html" || true
28         wget 'https://cvsweb.bsd.lv/~checkout~/mandoc/mandoc.css?rev=1.46&content-type=text/plain' -O man/mandoc.css
29         ln -sf "${PROJECT}.1.html" man/index.html
31     - name: Upload
32       env:
33         DEPLOY_TOKEN: ${{ secrets.GIT_DEPLOY_TOKEN }}
34       run: |
35         git clone --depth=1 --single-branch --branch gh-pages "https://x-access-token:${DEPLOY_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" /tmp/gh-pages
36         git config --global user.name "${GITHUB_ACTOR}"
37         git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
38         mkdir -p /tmp/gh-pages/man
39         rm -f /tmp/gh-pages/man/*
40         cp -av man/*.html /tmp/gh-pages/man/
41         cp -av man/*.css /tmp/gh-pages/man/
42         cd /tmp/gh-pages
43         git add -A && git commit --allow-empty -am "Publishing from ${GITHUB_REPOSITORY} ${GITHUB_SHA}"
44         git push origin gh-pages