chore: configure build output directory and disable Jekyll processing… #19
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: Deploy Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - next | |
| - "v*" | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/docs.yml' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Determine Base Path | |
| id: vars | |
| run: | | |
| BRANCH=${GITHUB_REF#refs/heads/} | |
| if [ "$BRANCH" = "main" ]; then | |
| echo "BASE=/express-cli/" >> $GITHUB_OUTPUT | |
| echo "FOLDER=." >> $GITHUB_OUTPUT | |
| elif [ "$BRANCH" = "next" ]; then | |
| echo "BASE=/express-cli/next/" >> $GITHUB_OUTPUT | |
| echo "FOLDER=next" >> $GITHUB_OUTPUT | |
| elif [[ $BRANCH == v* ]]; then | |
| # Extract major version, e.g., v1 from v1.x | |
| VERSION=$(echo $BRANCH | cut -d'.' -f1) | |
| echo "BASE=/express-cli/$VERSION/" >> $GITHUB_OUTPUT | |
| echo "FOLDER=$VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build with VitePress | |
| run: | | |
| pnpm run docs:build | |
| touch docs/.vitepress/dist/.nojekyll | |
| env: | |
| VITEPRESS_BASE: ${{ steps.vars.outputs.BASE }} | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: docs/.vitepress/dist | |
| destination_dir: ${{ steps.vars.outputs.FOLDER }} | |
| keep_files: true # CRITICAL: This keeps other versions alive! |