Skip to content

挖了个依赖注入的坑,慢慢做咯 #10

挖了个依赖注入的坑,慢慢做咯

挖了个依赖注入的坑,慢慢做咯 #10

Workflow file for this run

name: Create Reference Docs
on:
push:
tags:
- '**'
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-deploy:
name: 生成部署文档
runs-on: ubuntu-latest
steps:
- name: 检出
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
submodules: 'true'
- name: 主分支tag
id: tag_check
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
echo "on_master=false" >> $GITHUB_OUTPUT
exit 0
fi
TAG_REF="${GITHUB_REF}"
TAG_NAME="${TAG_REF#refs/tags/}"
TAG_COMMIT="$(git rev-list -n 1 "$TAG_REF")"
echo "Tag ${TAG_NAME} -> ${TAG_COMMIT}"
git fetch --no-tags origin master:origin/master
if git merge-base --is-ancestor "${TAG_COMMIT}" "origin/master"; then
echo "on_master=true" >> $GITHUB_OUTPUT
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
echo "tag_commit=${TAG_COMMIT}" >> $GITHUB_OUTPUT
else
echo "on_master=false" >> $GITHUB_OUTPUT
echo "Tag commit is not contained in 'master' branch. Skipping deployment."
fi
- name: 不在主分支的tag,直接放弃
if: steps.tag_check.outputs.on_master != 'true'
run: echo "No deployment tag not on master branch."
- name: 安装依赖
if: steps.tag_check.outputs.on_master == 'true'
run: |
sudo apt-get update
sudo apt-get install -y doxygen graphviz
- name: 编辑Doxyfile
if: steps.tag_check.outputs.on_master == 'true'
working-directory: api-doc
run: |
TAG="${{ steps.tag_check.outputs.tag_name }}"
# Escape sed replacement sensitive chars (/ and &)
ESCAPED_TAG=$(printf '%s' "$TAG" | sed -e 's/[\/&]/\\&/g')
sed -i "s/{{package_version}}/${ESCAPED_TAG}/g" Doxyfile
echo "Injected version '${TAG}' into Doxyfile"
- name: 构建
if: steps.tag_check.outputs.on_master == 'true'
working-directory: api-doc
run: |
set -e
doxygen Doxyfile || { echo 'Doxygen generation failed'; exit 1; }
if [ ! -d html ]; then
echo 'Expected output directory api-doc/html not found'; exit 2; fi
echo 'Doxygen docs generated successfully.'
- name: Configure GitHub Pages
if: steps.tag_check.outputs.on_master == 'true'
uses: actions/configure-pages@v4
- name: 上传产物
if: steps.tag_check.outputs.on_master == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: api-doc/html
- name: 部署
if: steps.tag_check.outputs.on_master == 'true'
id: deployment
uses: actions/deploy-pages@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}