This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy GitBook (via Docker) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Generate SUMMARY.md automatically | |
| run: | | |
| echo "# Summary" > SUMMARY.md | |
| echo "" >> SUMMARY.md | |
| echo "* [首页](README.md)" >> SUMMARY.md | |
| find . -type f -name "*.md" ! -name "README.md" ! -name "SUMMARY.md" \ | |
| | sort \ | |
| | while read file; do | |
| title=$(head -1 "$file" | sed 's/^#* //g' | xargs) | |
| echo "* [$title](${file#./})" >> SUMMARY.md | |
| done | |
| - name: Build GitBook using Docker | |
| run: | | |
| docker run --rm \ | |
| -v ${{ github.workspace }}:/gitbook \ | |
| -w /gitbook \ | |
| gitbook/nuts:3.1.1 \ | |
| bash -c "gitbook install && gitbook build" | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./_book |