-
Notifications
You must be signed in to change notification settings - Fork 157
70 lines (57 loc) · 2.48 KB
/
build-web-docs.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
name: Build HTML docs and deploy to gh-pages
on:
push:
branches:
- master # run on push to master (e.g., PR merge)
paths:
- '**.adoc' # run ONLY when an *.adoc file is created/modified
workflow_dispatch: # enables manual initiation of workflow from Actions tab of repo
jobs:
render-and-push-docs:
runs-on: ubuntu-latest
env: # set global environment variables
OUT_DIR: htmldocs
IMAGE_DIR: images
steps:
- name: Checkout LISF
uses: actions/checkout@v3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.6 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Install Asciidoctor
run: |
gem install asciidoctor
asciidoctor --version
- name: Render Docs
working-directory: ./docs # set working directory for following run command
run: |
# render index page
asciidoctor README.adoc --backend=html5 --destination-dir=${{ env.OUT_DIR }} --out-file index.html
# loop over directories in docs/
for DIR in */; do
# root doc file should have same name as the enclosing directory
# (e.g., LIS_users_guide/LIS_users_guide.adoc)
INFILE="${DIR}${DIR%/}.adoc"
DEST_DIR="${{ env.OUT_DIR }}/${DIR}"
# if the directory contains an asciidoc file of the same name
if [ -f ${INFILE} ]; then
# generate HTML version (asciidoctor-mathematical not needed for HTML)
echo "Converting ${INFILE} ......."
asciidoctor ${INFILE} --backend=html5 --destination-dir=${DEST_DIR}
else
echo "[WARN] ${DIR} does not contain an Asciidoc file of the same name. Skipping."
fi
done
# find images directories within doc directories
IMAGE_DIRS=$(find . -type d -name ${{ env.IMAGE_DIR }} -not -path "./${{ env.OUT_DIR }}/*")
# copy any image directories into the output directory
for DIR in ${IMAGE_DIRS}; do
cp -r ${DIR} ${{ env.OUT_DIR }}/${DIR}/
done
- name: Push ${{ env.OUT_DIR }}/ to gh-pages branch
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs/${{ env.OUT_DIR }} # The folder the action should deploy.