Skip to content

Commit 26f4f63

Browse files
committed
Add GitHub workflow to publish documentaton
Adds a github workflow to automatically publish API documentation as well as the other documentation from AtomVM/doc to the gihub pages website under the https://atomvm.net/doc directory (content was formerly hosted on a separate server at https://doc.atomvm.net). Signed-off-by: Winford <[email protected]>
1 parent 6382e1b commit 26f4f63

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#
2+
# Copyright 2023 Winford (Uncle Grumpy) <[email protected]>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
5+
#
6+
# This is a workflow for atomvm/AtomVM to Publish API documentation and other content from the `doc` directory to
7+
# atomvm.net hosted on GitHub Pages
8+
9+
name: Publish Docs
10+
11+
# Controls when the workflow will run
12+
on:
13+
# Triggers the workflow on push request events for all branches
14+
push:
15+
16+
# Allows you to run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
19+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
20+
jobs:
21+
# This workflow contains a single job called "build"
22+
build:
23+
# The type of runner that the job will run on
24+
runs-on: ubuntu-latest
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29+
30+
- name: Install Deps
31+
run: |
32+
sudo apt update -y
33+
DEBIAN_FRONTEND=noninteractive sudo apt install -y git cmake doxygen graphviz python3-pip python3-virtualenv python3-setuptools python3-stemmer wget
34+
35+
- uses: actions/cache@v3
36+
id: sphinx-cache
37+
with:
38+
path: /home/runner/python-env/sphinx
39+
key: ${{ runner.os }}-sphinx-install
40+
41+
- name: Install Sphinx
42+
if: steps.cache.outputs.sphinx-cache-hit != 'true'
43+
run: |
44+
python3 -m venv /home/runner/python-env/sphinx
45+
. /home/runner/python-env/sphinx/bin/activate
46+
python3 -m pip install sphinx
47+
python3 -m pip install myst-parser
48+
python3 -m pip install sphinx-rtd-theme
49+
python3 -m pip install rinohtype
50+
python3 -m pip install pillow
51+
python3 -m pip install gitpython
52+
python3 -m pip install breathe
53+
python3 -m pip install pygments
54+
55+
- uses: erlef/setup-beam@v1
56+
with:
57+
otp-version: "24"
58+
elixir-version: "1.14"
59+
60+
- name: Install rebar3
61+
working-directory: /tmp
62+
run: |
63+
wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
64+
./rebar3 local install
65+
echo "/home/runner/.cache/rebar3/bin" >> ${GITHUB_PATH}
66+
67+
- uses: erlef/setup-beam@v1
68+
with:
69+
otp-version: "24"
70+
elixir-version: "1.14"
71+
72+
- uses: actions/checkout@v3
73+
with:
74+
repository: atomvm/AtomVM
75+
fetch-depth: 0
76+
77+
- uses: actions/checkout@v3
78+
id: checkout-production
79+
with:
80+
repository: atomvm/atomvm_www
81+
ref: Production
82+
path: /home/runner/work/AtomVM/AtomVM/www
83+
84+
- name: Build Site
85+
run: |
86+
. /home/runner/python-env/sphinx/bin/activate
87+
for remote in `git branch -r | grep -v /HEAD | grep -v ${{ github.ref_name }}`; do git checkout --track $remote; done
88+
git switch ${{ github.ref_name }}
89+
git branch
90+
mkdir build
91+
cd build
92+
cmake ..
93+
cd doc
94+
make GitHub_CI_Publish_Docs
95+
96+
- name: Commit files
97+
working-directory: /home/runner/work/AtomVM/AtomVM/www
98+
run: |
99+
git checkout Production
100+
git config --local user.email "[email protected]"
101+
git config --local user.name "AtomVM Doc Bot"
102+
git add .
103+
git commit -m "Update Documentation"
104+
- name: Push changes
105+
working-directory: /home/runner/work/AtomVM/AtomVM/www
106+
run: |
107+
eval `ssh-agent -t 60 -s`
108+
echo "${{ secrets.PUBLISH_ACTION_KEY }}" | ssh-add -
109+
mkdir -p ~/.ssh/
110+
ssh-keyscan github.com >> ~/.ssh/known_hosts
111+
git remote add push_dest "[email protected]:atomvm/atomvm_www.git"
112+
git fetch push_dest
113+
git push --set-upstream push_dest Production
114+

doc/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ if(SPHINX_FOUND)
122122
DEPENDS ${ERLANG_DOTFILE_TARGETS} ${ERLANG_EDOC_TARGETS} ${CMAKE_CURRENT_BINARY_DIR}/conf.py
123123
)
124124

125+
## This target is intended for CI `Publish Docs` workflow.
126+
if ($ENV{CI})
127+
add_custom_target(GitHub_CI_Publish_Docs
128+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/html /home/runner/work/AtomVM/AtomVM/www/doc/${BRANCH_NAME}
129+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
130+
COMMENT "Copying html docs to publish location /home/runner/work/AtomVM/AtomVM/www/doc/${BRANCH_NAME}." VERBATIM
131+
DEPENDS doc /home/runner/work/AtomVM/AtomVM/www/doc $ENV{BRANCH_NAME}
132+
)
133+
endif()
134+
125135
else()
126136
message("Unable to find Sphinx -- no Sphinx documentation will be generated")
127137
endif()
@@ -140,3 +150,35 @@ add_custom_target(doc #ALL
140150
DEPENDS ${ERLANG_EDOC_TARGETS} sphinx-html sphinx-pdf sphinx-epub
141151
)
142152

153+
if (TARGET GitHub_CI_Publish_Docs)
154+
155+
add_custom_command(
156+
COMMAND mkdir -p /home/runner/work/AtomVM/AtomVM/www/doc
157+
OUTPUT /home/runner/work/AtomVM/AtomVM/www/doc
158+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
159+
COMMENT "Prepare publish directory structure." VERBATIM
160+
)
161+
162+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/pdf)
163+
add_custom_command(TARGET sphinx-pdf POST_BUILD
164+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/pdf/AtomVM-${BRANCH_NAME}.pdf ${CMAKE_CURRENT_BINARY_DIR}/html/pdf/
165+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdf
166+
COMMENT "Copying pdf to download location" VERBATIM
167+
DEPENDS $ENV{BRANCH_NAME}
168+
)
169+
170+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/epub)
171+
add_custom_command(TARGET sphinx-epub POST_BUILD
172+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/epub/AtomVM-${BRANCH_NAME}.epub" "${CMAKE_CURRENT_BINARY_DIR}/html/epub/"
173+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/epub
174+
COMMENT "Copying epub to download location." VERBATIM
175+
DEPENDS $ENV{BRANCH_NAME}
176+
)
177+
178+
add_custom_command(TARGET sphinx-html POST_BUILD
179+
COMMAND touch .nojekyll
180+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
181+
COMMENT "Creating .nojekyll to allow style content on GitHub Pages." VERBATIM
182+
)
183+
184+
endif()

0 commit comments

Comments
 (0)