Skip to content

Commit 6507449

Browse files
committed
ci: Add GitHub Workflow to build and publish documentation
1 parent 7714c1a commit 6507449

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/build-doxygen.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build and Publish
2+
3+
on:
4+
# Allows running this workflow manually from the Actions tab
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "Version of Slicer documentation to build and publish"
9+
required: true
10+
11+
permissions:
12+
# Needed in the publish step to update gh-pages branch
13+
contents: write
14+
15+
jobs:
16+
build-and-publish:
17+
env:
18+
JCFR_TEST_BRANCH: speedup-doxygen-generation-2
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Collect Inputs
22+
id: collect_inputs
23+
run: |
24+
echo "EVENT_NAME [$EVENT_NAME]"
25+
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
26+
version=${{ github.event.inputs.version }}
27+
else
28+
echo "::error ::Unsupported EVENT_NAME [$EVENT_NAME]"
29+
exit 1
30+
fi
31+
echo "version=$version" >> $GITHUB_OUTPUT
32+
env:
33+
EVENT_NAME: ${{ github.event_name }}
34+
35+
- uses: actions/checkout@v4
36+
with:
37+
ref: gh-pages
38+
path: gh-pages
39+
40+
- uses: actions/checkout@v4
41+
with:
42+
repository: jcfr/Slicer
43+
path: Slicer
44+
ref: ${{ env.JCFR_TEST_BRANCH }} # ${{ steps.collect_inputs.outputs.version }}
45+
46+
- uses: ssciwr/doxygen-install@v1
47+
with:
48+
version: "1.10.0"
49+
50+
# The "dot" binary is provided by Graphviz
51+
- uses: ts-graphviz/setup-graphviz@v2
52+
53+
- uses: actions/checkout@v4
54+
with:
55+
repository: Slicer/slicer-apidocs-builder
56+
path: slicer-apidocs-builder
57+
ref: 1744509e91fa66186d34e4c6968ee684131c51d1
58+
59+
- uses: actions/setup-python@v5
60+
with:
61+
python-version: '3.13'
62+
cache: 'pip'
63+
64+
- name: Install slicer-apidocs-builder
65+
run: |
66+
pip install ./slicer-apidocs-builder
67+
68+
- name: Generate Documentation
69+
run: |
70+
slicer-apidocs-builder \
71+
--skip-publish \
72+
--slicer-repo-dir Slicer \
73+
--slicer-repo-branch "$SLICER_REPO_BRANCH" \
74+
--slicer-repo-tag "${SLICER_REPO_TAG}"
75+
env:
76+
SLICER_REPO_BRANCH: ${{ env.JCFR_TEST_BRANCH }} # ${{ steps.collect_inputs.outputs.version }}
77+
SLICER_REPO_TAG: ""
78+
79+
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
80+
id: app-token
81+
with:
82+
app-id: ${{ vars.SLICER_APP_ID }}
83+
private-key: ${{ secrets.SLICER_APP_PRIVATE_KEY }}
84+
85+
- name: Rename Directory
86+
run: |
87+
mv \
88+
/tmp/Slicer-Slicer-$JCFR_TEST_BRANCH-build \
89+
/tmp/Slicer-Slicer-$SLICER_REPO_BRANCH-build
90+
env:
91+
SLICER_REPO_BRANCH: ${{ steps.collect_inputs.outputs.version }}
92+
93+
- name: Publish documentation
94+
run: |
95+
slicer-apidocs-builder \
96+
--skip-build \
97+
--slicer-repo-name ${SLICER_REPO_NAME} \
98+
--slicer-repo-branch "${SLICER_REPO_BRANCH}" \
99+
--slicer-repo-tag "${SLICER_REPO_TAG}" \
100+
--publish-github-repo-name "Slicer/${PUBLISH_GITHUB_PROJECT_NAME}" \
101+
--publish-github-repo-branch gh-pages
102+
env:
103+
PUBLISH_GITHUB_PROJECT_NAME: apidocs.slicer.org
104+
PUBLISH_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
105+
SLICER_REPO_NAME: Slicer/Slicer
106+
SLICER_REPO_BRANCH: ${{ steps.collect_inputs.outputs.version }}
107+
SLICER_REPO_TAG: ""
108+

0 commit comments

Comments
 (0)