はじめに
GitHub Actions から C++ のクラス図を自動で生成し、README などの Markdonw ドキュメントから参照できるようにする方法についてまとめます。
サンプル
後ほど解説をまとめます。
name: documentation
on:
push:
branches:
- master
paths-ignore:
- "docs/**"
- "**.md"
jobs:
generate_plantuml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: "11"
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
sudo apt install -y graphviz
pip install hpp2plantuml
- name: Generate PlantUML
run: |
mkdir -p docs/pu
hpp2plantuml -i "./**/*.h*" -o docs/pu/class.pu
java -jar ./tools/plantuml/plantuml.jar -svg ./docs/pu/class.pu -charset UTF-8
- name: Count changes
id: changes
run: |
git add -N .
echo "::set-output name=count::$(git diff --name-only | wc -l)"
- name: Commit files
if: steps.changes.outputs.count > 0
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add ./docs/
git commit -m "generated"
- name: Push changes
uses: ad-m/github-push-action@master
with:
force_with_lease: true