WIP: Try changing base URL for preview action #12
Workflow file for this run
This file contains 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
# Deploy preview of the website for PRs | |
name: Deploy PR Previews | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- closed | |
workflow_dispatch: | |
concurrency: preview-${{ github.ref }} | |
permissions: | |
contents: write # TODO: do we want this? | |
pages: write | |
actions: write | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Hugo CLI | |
run: | | |
wget -O hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.128.0/hugo_extended_0.128.0_linux-amd64.deb \ | |
&& sudo dpkg -i hugo.deb | |
- name: Install Node.js dependencies | |
run: | | |
if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then npm ci; else npm install; fi | |
- name: Build Hugo Site | |
if: github.event.action != 'closed' | |
env: | |
HUGO_ENVIRONMENT: preview | |
run: | | |
echo "Building site with baseURL: https://${{ github.repository_owner }}.github.io/pr-preview/pr-${{ github.event.number }}/" | |
hugo --environment preview --baseURL "https://${{ github.repository_owner }}.github.io/pr-preview/pr-${{ github.event.number }}/" --minify -d public | |
- name: List Public Directory | |
if: github.event.action != 'closed' | |
run: | | |
echo "Contents of the public directory:" | |
ls -R public | |
- name: Check Base URL in Generated HTML | |
if: github.event.action != 'closed' | |
run: | | |
echo "Checking base URL in generated HTML files:" | |
grep -r "https://${{ github.repository_owner }}.github.io/pr-preview/pr-${{ github.event.number }}/" public || echo "Base URL not found in some files" | |
- name: Deploy PR Preview | |
uses: rossjrw/pr-preview-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
source-dir: ./public | |
pages-base-url: https://${{ github.repository_owner }}.github.io/ | |
action: auto |