v1.5.1 #60
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: Docs | |
| on: | |
| push: | |
| branches: [develop] | |
| release: | |
| types: [published] | |
| concurrency: | |
| group: docs-deploy | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: "22" | |
| PYTHON_VERSION: "3.14" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| path: release | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: develop | |
| fetch-depth: 0 | |
| path: develop | |
| - name: Determine release ref | |
| id: release-ref | |
| working-directory: release | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| REF="${{ github.event.release.tag_name }}" | |
| else | |
| DEFAULT_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') | |
| REF=$(git tag --list 'v*' --sort=-version:refname | head -1) | |
| REF="${REF:-$DEFAULT_BRANCH}" | |
| fi | |
| echo "ref=${REF}" >> "$GITHUB_OUTPUT" | |
| - name: Checkout release ref | |
| working-directory: release | |
| run: git checkout "${{ steps.release-ref.outputs.ref }}" | |
| - name: Check if release ref has docs | |
| id: check-release-docs | |
| working-directory: release | |
| run: | | |
| if [ -f docs/package.json ] && [ -f docs/.vitepress/config.ts ]; then | |
| echo "has_docs=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_docs=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: npm | |
| cache-dependency-path: | | |
| release/docs/package-lock.json | |
| develop/docs/package-lock.json | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Generate DB layout docs (release) | |
| if: steps.check-release-docs.outputs.has_docs == 'true' | |
| working-directory: release/docs | |
| run: npm run docs:gen-db 2>/dev/null || echo "Skipped — docs:gen-db not in this release" | |
| - name: Build release docs | |
| if: steps.check-release-docs.outputs.has_docs == 'true' | |
| working-directory: release/docs | |
| run: | | |
| npm ci | |
| npx vitepress build | |
| mv .vitepress/dist /tmp/dist-release | |
| - name: Generate DB layout docs (nightly) | |
| working-directory: develop/docs | |
| run: npm run docs:gen-db | |
| - name: Build nightly docs | |
| working-directory: develop/docs | |
| run: | | |
| npm ci | |
| cp .vitepress/config.ts .vitepress/config.original.ts | |
| cp .vitepress/config.nightly.ts .vitepress/config.ts | |
| npx vitepress build | |
| mv .vitepress/dist /tmp/dist-nightly | |
| - name: Prepare full deploy (release + nightly) | |
| if: steps.check-release-docs.outputs.has_docs == 'true' | |
| run: | | |
| mv /tmp/dist-release ./dist | |
| mkdir -p ./dist/next | |
| cp -a /tmp/dist-nightly/. ./dist/next/ | |
| - name: Prepare nightly-only deploy | |
| if: steps.check-release-docs.outputs.has_docs != 'true' | |
| run: cp -a /tmp/dist-nightly/. ./dist/ | |
| - name: Write version.json | |
| run: | | |
| VERSION="${{ steps.release-ref.outputs.ref }}" | |
| RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/${VERSION}" | |
| printf '{"version":"%s","release_url":"%s"}\n' "$VERSION" "$RELEASE_URL" > ./dist/version.json | |
| - name: Write CNAME | |
| run: | | |
| printf 'docs.librislog.app\n' > ./dist/CNAME | |
| - uses: peaceiris/actions-gh-pages@v4 | |
| if: steps.check-release-docs.outputs.has_docs == 'true' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| keep_files: false | |
| - uses: peaceiris/actions-gh-pages@v4 | |
| if: steps.check-release-docs.outputs.has_docs != 'true' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| destination_dir: next | |
| keep_files: false |