fix: update site URLs and base path for deployment to petk.dev #4
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 Docusaurus to GitHub Pages | |
| # Workflow triggers | |
| on: | |
| # Trigger on pushes to main branch | |
| push: | |
| branches: | |
| - main | |
| # Only trigger when docs-related files change | |
| paths: | |
| - 'apps/docs/**' | |
| - 'package.json' | |
| - 'pnpm-lock.yaml' | |
| - '.github/workflows/deploy-docs.yml' | |
| # Allow manual workflow dispatch | |
| workflow_dispatch: | |
| # Set permissions for GitHub token | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| # Environment variables | |
| env: | |
| NODE_VERSION: '20' | |
| PNPM_VERSION: '9' | |
| jobs: | |
| # Build job | |
| build: | |
| name: Build Docusaurus Site | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for git info | |
| # Step 2: Setup pnpm | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| run_install: false | |
| # Step 3: Setup Node.js with pnpm cache | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'pnpm' | |
| # Step 4: Get pnpm store directory for caching | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| # Step 5: Setup pnpm cache | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| # Step 6: Setup Turborepo cache | |
| - name: Setup Turborepo cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .turbo | |
| key: ${{ runner.os }}-turbo-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-turbo- | |
| # Step 7: Install dependencies | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| env: | |
| HUSKY: 0 # Disable Husky hooks during CI | |
| # Step 8: Build Docusaurus site | |
| - name: Build Docusaurus site | |
| run: pnpm --filter apps-docs build | |
| env: | |
| NODE_ENV: production | |
| # GitHub Pages specific configurations | |
| DOCUSAURUS_URL: https://petk.dev | |
| DOCUSAURUS_BASE_URL: / | |
| # Step 9: Setup Pages | |
| - name: Setup GitHub Pages | |
| uses: actions/configure-pages@v5 | |
| # Step 10: Upload build artifacts | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./apps/docs/build | |
| # Deploy job | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| # Deploy to GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # Optional: Add status check job for PR protection | |
| status-check: | |
| name: Documentation Build Status | |
| runs-on: ubuntu-latest | |
| needs: [build, deploy] | |
| if: always() | |
| steps: | |
| - name: Check deployment status | |
| run: | | |
| if [ "${{ needs.build.result }}" == "success" ] && [ "${{ needs.deploy.result }}" == "success" ]; then | |
| echo "✅ Documentation successfully deployed to GitHub Pages" | |
| echo "📍 URL: https://petk.dev/" | |
| exit 0 | |
| else | |
| echo "❌ Documentation deployment failed" | |
| echo "Build status: ${{ needs.build.result }}" | |
| echo "Deploy status: ${{ needs.deploy.result }}" | |
| exit 1 | |
| fi | |
| # Workflow metadata for status badges | |
| # To add a status badge to your README: | |
| # [](https://github.com/mihazs/actions/workflows/deploy-docs.yml) |