Update hugo.toml (preview test) #14
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 Preview Docs | |
| on: | |
| pull_request_target: | |
| branches: [master] | |
| types: [opened, synchronize, reopened, closed] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: preview-${{ github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build-and-deploy-preview: | |
| runs-on: ubuntu-24.04 | |
| env: | |
| HUGO_VERSION: 0.158.0 | |
| steps: | |
| - name: Checkout PR code | |
| if: github.event.action != 'closed' | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Checkout for cleanup | |
| if: github.event.action == 'closed' | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: gh-pages | |
| fetch-depth: 0 | |
| - name: Install Hugo CLI | |
| if: github.event.action != 'closed' | |
| run: | | |
| wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
| && sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
| - name: Install Dart Sass | |
| if: github.event.action != 'closed' | |
| run: sudo snap install dart-sass | |
| - name: Setup Node | |
| if: github.event.action != 'closed' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install dependencies | |
| if: github.event.action != 'closed' | |
| run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | |
| - name: Build PR preview | |
| if: github.event.action != 'closed' | |
| env: | |
| HUGO_ENVIRONMENT: production | |
| HUGO_ENV: production | |
| HUGO_PREVIEW: "true" | |
| run: | | |
| hugo \ | |
| --gc \ | |
| --minify \ | |
| --baseURL "/" | |
| cat > public/robots.txt <<'EOF' | |
| User-agent: * | |
| Disallow: / | |
| EOF | |
| - name: Deploy PR preview | |
| if: github.event.action != 'closed' | |
| uses: rossjrw/pr-preview-action@v1.6.3 | |
| with: | |
| source-dir: ./public | |
| preview-branch: gh-pages | |
| umbrella-dir: pr-preview | |
| action: auto | |
| comment: false | |
| - name: Comment PR with Preview URL | |
| if: github.event.action != 'closed' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: pr-preview | |
| message: | | |
| 🚀 **Preview deployment for PR #${{ github.event.pull_request.number }}** | |
| 🌐 **Preview URL**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/ | |
| _This preview will be updated automatically when you push new commits to this PR._ | |
| - name: Cleanup PR preview on close | |
| if: github.event.action == 'closed' | |
| uses: rossjrw/pr-preview-action@v1.6.3 | |
| with: | |
| preview-branch: gh-pages | |
| umbrella-dir: pr-preview | |
| action: remove |