From 5319e02c7c594617a9e0bb9f1bb78edb6cf0a163 Mon Sep 17 00:00:00 2001 From: yunwei37 Date: Sun, 5 Oct 2025 20:59:51 -0700 Subject: [PATCH] feat: add workflow for auto-generating documentation on push --- .github/workflows/auto-generate-docs.yml | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/auto-generate-docs.yml diff --git a/.github/workflows/auto-generate-docs.yml b/.github/workflows/auto-generate-docs.yml new file mode 100644 index 0000000..8b16bee --- /dev/null +++ b/.github/workflows/auto-generate-docs.yml @@ -0,0 +1,45 @@ +name: Auto Generate Documentation + +on: + push: + paths: + - 'src/**/README.md' + - 'src/**/README.zh.md' + - 'src/**/.config' + - 'scripts/generate_toc.py' + - 'scripts/*.template' + workflow_dispatch: + +jobs: + generate-docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Generate documentation + run: | + python3 scripts/generate_toc.py + + - name: Check for changes + id: check_changes + run: | + git diff --quiet || echo "has_changes=true" >> $GITHUB_OUTPUT + + - name: Commit and push changes + if: steps.check_changes.outputs.has_changes == 'true' + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add README.md README.zh.md src/SUMMARY.md src/SUMMARY.zh.md + git commit -m "docs: auto-generate documentation" + git push