Skip to content

Commit 9635a22

Browse files
committed
ENH: Add GitHub workflow to trigger Doxygen build and publish
This commit introduces the `trigger-doxygen-build-and-publish.yml` workflow, which triggers the `doxygen-build-and-publish.yml` workflow maintained in the `Slicer/apidocs.slicer.org` repository. The trigger occurs whenever the `main` branch is updated or a new tag is pushed, resulting in the build and publication of the corresponding Doxygen documentation at https://apidocs.slicer.org. For security reasons, this workflow is not triggered by the `pull_request` event. This restriction prevents untrusted code from exploiting short-lived tokens with elevated permissions. The workflow internally configures a dummy CMake project that includes the `Utilities/Doxygen` sub-directory, which could otherwise expose sensitive information if executed with arbitrary code.
1 parent 423c46a commit 9635a22

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Trigger Doxygen Build and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
10+
# Allows running this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
inputs:
13+
slicer_repository:
14+
description: "Slicer Repository for which to build and publish the documentation"
15+
default: Slicer/Slicer
16+
slicer_ref:
17+
description: "Slicer Branch or tag for which to build and publish the documentation"
18+
default: main
19+
preview:
20+
description: "Publish at https://preview.apidocs.slicer.org"
21+
default: false
22+
type: boolean
23+
24+
permissions:
25+
# Needed to trigger workflow run
26+
actions: write
27+
28+
jobs:
29+
doxygen-build-and-publish:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Collect Inputs
33+
id: collect_inputs
34+
run: |
35+
echo "EVENT_NAME [$EVENT_NAME]"
36+
if [[ "$EVENT_NAME" == "push" ]]; then
37+
slicer_repository=${{ github.repository }}
38+
39+
github_ref=${{ github.ref }}
40+
echo "github_ref [$github_ref]"
41+
# Strip 'refs/heads/' or 'refs/tags/' from the start of the string
42+
slicer_ref="${github_ref#refs/heads/}"
43+
slicer_ref="${slicer_ref#refs/tags/}"
44+
45+
preview="false"
46+
47+
elif [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
48+
slicer_repository=${{ github.event.inputs.slicer_repository }}
49+
slicer_ref=${{ github.event.inputs.ref }}
50+
preview=${{ github.event.inputs.preview }}
51+
52+
else
53+
echo "::error ::Unsupported EVENT_NAME [$EVENT_NAME]"
54+
exit 1
55+
fi
56+
57+
echo "slicer_repository [$slicer_repository]"
58+
echo "slicer_repository=$slicer_repository" >> $GITHUB_OUTPUT
59+
60+
echo "slicer_ref [$slicer_ref]"
61+
echo "slicer_ref=$slicer_ref" >> $GITHUB_OUTPUT
62+
63+
echo "preview [$preview]"
64+
echo "preview=$preview" >> $GITHUB_OUTPUT
65+
env:
66+
EVENT_NAME: ${{ github.event_name }}
67+
68+
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
69+
id: app-token
70+
with:
71+
app-id: ${{ vars.SLICER_APP_ID }}
72+
private-key: ${{ secrets.SLICER_APP_PRIVATE_KEY }}
73+
owner: Slicer
74+
repositories: |
75+
apidocs.slicer.org
76+
77+
- name: Trigger Workflow
78+
run: |
79+
gh workflow run doxygen-build-and-publish.yml \
80+
-f slicer_repository=$SLICER_REPOSITORY \
81+
-f slicer_ref=$SLICER_REF \
82+
-f preview=$PREVIEW \
83+
--repo "Slicer/apidocs.slicer.org"
84+
env:
85+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
86+
SLICER_REPOSITORY: ${{ steps.collect_inputs.outputs.slicer_repository }}
87+
SLICER_REF: ${{ steps.collect_inputs.outputs.slicer_ref }}
88+
PREVIEW: ${{ steps.collect_inputs.outputs.preview }}

0 commit comments

Comments
 (0)