Skip to content

Commit a5c9d9c

Browse files
committed
Add reusable workflow
1 parent eee275a commit a5c9d9c

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.github/workflows/render-docs.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: 'Generate and Commit Docs'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
source-path:
7+
description: 'Source path containing the .h files'
8+
required: true
9+
type: string
10+
target-path:
11+
description: 'Target path or file for the markdown documentation'
12+
required: true
13+
type: string
14+
exclude-pattern:
15+
description: 'Pattern for excluding files (e.g. "*/test/*")'
16+
type: string
17+
include-cpp:
18+
description: 'Include .cpp files'
19+
default: false
20+
type: boolean
21+
access-level:
22+
description: 'The minimum access level to be considered in the documentation'
23+
default: 'public'
24+
type: string
25+
show-access-modifiers:
26+
description: 'Show access modifiers in the documentation'
27+
default: false
28+
type: boolean
29+
fail-on-warnings:
30+
description: 'Fail when documentation warnings are issued.'
31+
default: false
32+
type: boolean
33+
commit:
34+
description: 'Boolean flag to indicate whether to commit changes'
35+
default: true
36+
type: boolean
37+
commit-message:
38+
description: 'Commit message'
39+
default: 'Update documentation'
40+
type: string
41+
debug:
42+
description: 'Enable debugging mode to provide additional output'
43+
default: false
44+
type: boolean
45+
46+
jobs:
47+
render-docs:
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Install doxygen dependencies
54+
shell: bash
55+
run: |
56+
# Import LLVM GPG key without using apt-key
57+
wget -q -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
58+
59+
# Add the LLVM repository with the GPG keyring
60+
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/focal/ llvm-toolchain-focal-9 main" | sudo tee /etc/apt/sources.list.d/llvm.list > /dev/null
61+
62+
# Update the package lists
63+
sudo apt-get -qq update
64+
65+
# Install libclang and other necessary packages
66+
sudo apt-get -qq install -y libclang1-9 libclang-cpp9 > /dev/null
67+
68+
- name: Set up Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: 20
72+
73+
- name: Install render-docs
74+
shell: bash
75+
run: npm install github:sebromero/render-docs --no-save --silent
76+
77+
- name: Cache Doxygen binaries
78+
id: cache-doxygen-binaries
79+
uses: actions/cache@v4
80+
with:
81+
path: |
82+
node_modules/doxygen/dist
83+
key: ${{ runner.os }}-doxygen-binaries-${{ hashFiles('node_modules/doxygen/lib/constants.js') }}
84+
85+
- name: Run Docs Generation
86+
shell: bash
87+
run: |
88+
npx render-docs \
89+
${{ inputs.source-path }} \
90+
${{ inputs.target-path }} \
91+
${{ inputs.exclude-pattern && format('--exclude {0}', inputs.exclude-pattern) || '' }} \
92+
${{ inputs.include-cpp == true && '--include-cpp' || '' }} \
93+
${{ inputs.show-access-modifiers == true && '--show-access-modifiers' || '' }} \
94+
${{ inputs.access-level && format('--access-level {0}', inputs.access-level) || '' }} \
95+
${{ inputs.fail-on-warnings == true && '--fail-on-warnings' || '' }} \
96+
${{ inputs.debug == true && '--debug ' || '' }}
97+
98+
- name: Commit Docs
99+
if: inputs.commit
100+
uses: EndBug/add-and-commit@v9
101+
with:
102+
add: "${{ inputs.target-path }}"
103+
author_name: "GitHub Action"
104+
author_email: "action@github.com"
105+
message: "${{ inputs.commit-message }}"

0 commit comments

Comments
 (0)