|
| 1 | +name: Build Hugo Preview |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - ".github/workflows/pages.yml" |
| 9 | + - ".github/workflows/hugo-preview.yml" |
| 10 | + - "hugo-docs/**" |
| 11 | + - "feature-announcements/**" |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths: |
| 16 | + - ".github/workflows/pages.yml" |
| 17 | + - ".github/workflows/hugo-preview.yml" |
| 18 | + - "hugo-docs/**" |
| 19 | + - "feature-announcements/**" |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: "hugo-preview-${{ github.ref }}" |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +defaults: |
| 30 | + run: |
| 31 | + shell: bash |
| 32 | + |
| 33 | +jobs: |
| 34 | + build-preview: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + env: |
| 37 | + HUGO_VERSION: "0.158.0" |
| 38 | + PREVIEW_BASEURL: "http://127.0.0.1:1313/" |
| 39 | + steps: |
| 40 | + - name: Checkout repository |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: Setup Go |
| 46 | + uses: actions/setup-go@v5 |
| 47 | + with: |
| 48 | + go-version: "1.22" |
| 49 | + |
| 50 | + - name: Install Hugo CLI |
| 51 | + run: | |
| 52 | + wget -O "${{ runner.temp }}/hugo.deb" \ |
| 53 | + "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" |
| 54 | + sudo dpkg -i "${{ runner.temp }}/hugo.deb" |
| 55 | +
|
| 56 | + - name: Download Hugo modules |
| 57 | + working-directory: ./hugo-docs |
| 58 | + run: hugo mod tidy |
| 59 | + |
| 60 | + - name: Build Hugo preview site |
| 61 | + working-directory: ./hugo-docs |
| 62 | + env: |
| 63 | + HUGO_ENVIRONMENT: production |
| 64 | + HUGO_BASEURL: ${{ env.PREVIEW_BASEURL }} |
| 65 | + run: hugo --gc --minify |
| 66 | + |
| 67 | + - name: Upload Hugo preview artifact |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: hugo-preview-${{ github.run_number }} |
| 71 | + path: ./hugo-docs/public |
| 72 | + if-no-files-found: error |
| 73 | + retention-days: 7 |
| 74 | + |
| 75 | + - name: Publish preview instructions |
| 76 | + run: | |
| 77 | + { |
| 78 | + echo "## Hugo branch preview" |
| 79 | + echo |
| 80 | + echo "Artifact: \`hugo-preview-${{ github.run_number }}\`" |
| 81 | + echo |
| 82 | + echo "After downloading the artifact, serve the extracted \`public/\` directory locally:" |
| 83 | + echo |
| 84 | + echo "\`\`\`bash" |
| 85 | + echo "python -m http.server 1313 -d public" |
| 86 | + echo "\`\`\`" |
| 87 | + echo |
| 88 | + echo "Then verify:" |
| 89 | + echo |
| 90 | + echo "- http://127.0.0.1:1313/docs/talks/chennai-foss-2026/" |
| 91 | + echo "- http://127.0.0.1:1313/feature-announcements/chennai-foss-2026/idp-onboarding-demo.html" |
| 92 | + echo |
| 93 | + echo "For a one-off hosted check, you can still run the production Pages workflow manually on this branch, but that deploys to the shared GitHub Pages environment." |
| 94 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments