Merge pull request #150 from SongshGeoLab/dev #113
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: gh-page | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| - dev | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Dry-run build (no deploy)' | |
| required: false | |
| default: 'false' | |
| # 添加并发控制,防止多个部署任务同时推送到gh-pages分支 | |
| concurrency: | |
| group: pages-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| if: github.event.repository.fork == false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整历史,mike需要访问gh-pages分支 | |
| - name: Configure Git Credentials | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| # ===================== UV only ===================== | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Install dependencies (uv) | |
| run: | | |
| set -e | |
| # Install runtime + docs group (mkdocs, plugins, nb toolchain) | |
| uv sync --group docs --dev | |
| if [ -n "${{ secrets.GH_TOKEN }}" ]; then | |
| uv pip install git+https://${{ secrets.GH_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git | |
| else | |
| echo "GH_TOKEN not set; installing mkdocs-material (public) instead" | |
| uv pip install mkdocs-material | |
| fi | |
| # mkdocs-jupyter handles notebooks at build time; no manual conversion needed | |
| # ======================== Dry-run build ======================== | |
| - name: Build docs only (dry-run) | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == 'true' }} | |
| run: | | |
| uv run mkdocs build --strict | |
| # ========================= Deploy steps ======================== | |
| - name: Deploy documentation (dev branch) | |
| if: ${{ (github.event_name != 'workflow_dispatch' || inputs.dry_run != 'true') && github.ref == 'refs/heads/dev' }} | |
| run: | | |
| git fetch origin gh-pages --depth=1 || true | |
| uv run mike deploy --push dev | |
| - name: Deploy documentation (master branch) | |
| if: ${{ (github.event_name != 'workflow_dispatch' || inputs.dry_run != 'true') && github.ref == 'refs/heads/master' }} | |
| run: | | |
| git fetch origin gh-pages --depth=1 || true | |
| uv run mike deploy --push --update-aliases 0.8 latest | |
| uv run mike set-default --push latest | |
| - name: Deploy documentation (version tags) | |
| if: ${{ (github.event_name != 'workflow_dispatch' || inputs.dry_run != 'true') && startsWith(github.ref, 'refs/tags/v') }} | |
| run: | | |
| git fetch origin gh-pages --depth=1 || true | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| MAJOR_MINOR=$(echo $VERSION | cut -d. -f1-2) | |
| uv run mike deploy --push --update-aliases $MAJOR_MINOR latest | |
| uv run mike set-default --push latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |