Skip to content

[Docs] Resolve .Site.AllPages deprecation #8

[Docs] Resolve .Site.AllPages deprecation

[Docs] Resolve .Site.AllPages deprecation #8

name: Build and Preview Site
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-latest
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
fetch-depth: 0
- name: Checkout for cleanup
if: github.event.action == 'closed'
uses: actions/checkout@v6
with:
ref: gh-pages
fetch-depth: 0
- name: Setup Go
if: github.event.action != 'closed'
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Setup Hugo Extended
if: github.event.action != 'closed'
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.158.0'
extended: true
- name: Setup Node
if: github.event.action != 'closed'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup site dependencies
if: github.event.action != 'closed'
run: make setup
- name: Build PR preview
if: github.event.action != 'closed'
run: |
make build-preview BASE_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/"
touch public/.nojekyll
- 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