Skip to content

Add pr preview

Add pr preview #37

Workflow file for this run

name: Deploy Hugo site to Pages
on:
push:
branches: ["master"]
pull_request:
types:
- opened
- reopened
- synchronize
- closed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pull-requests: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
# Default to bash
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.114.0
steps:
- name: Install Hugo CLI
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
run: sudo snap install dart-sass
#
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Set base URL for PRs
if: github.event_name == 'pull_request'
run: |
echo "OUTPUT_URL=pedestriandynamics.github.io/pedestriandynamics-preview/pr-preview/pr-${{ github.event.number }}" >> "$GITHUB_ENV"
- name: Set base URL for Release
if: github.event_name == 'push'
run: |
echo "OUTPUT_URL=${{ steps.pages.outputs.base_url }}" >> "$GITHUB_ENV"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
echo "${{ env.OUTPUT_URL }}/"
hugo \
--minify \
--baseURL "${{ env.OUTPUT_URL }}"
- name: "check is PR_PREVIEW exists"
env:
super_secret: ${{ secrets.PR_PREVIEW }}
if: ${{ env.super_secret == '' }}
run:
echo "echo the secret \"PR_PREVIEW\" has not been made; echo please go to \"settings \> secrets \> actions\" to create it"
- name: Deploy preview
if: github.event_name == 'pull_request'
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./public/
deploy-repository: PedestrianDynamics/pedestriandynamics-preview
token: ${{ secrets.PEDESTRIANDYNAMICS_PR_PREVIEW }}
- name: Deploy pedestriandynamics.org
if: github.event_name == 'push'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./public/
branch: gh-pages
clean-exclude: pr-preview/
force: false
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: pages
path: ./public/