Skip to content

Commit

Permalink
feat: add workflow to preview prs
Browse files Browse the repository at this point in the history
  • Loading branch information
f-hollow committed Jul 6, 2024
1 parent e595b4d commit f83b958
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/preview-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Preview Hugo Site

on:
pull_request:
branches:
- main

# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

# Default to bash
defaults:
run:
shell: bash

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Install Hugo CLI
env:
HUGO_VERSION: 0.120.4
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: Check out repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build the site
run: hugo --minify

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
# Deploy to a subdirectory for each PR
destination_dir: "preview/${{ github.event.number }}-${{ github.sha }}"

0 comments on commit f83b958

Please sign in to comment.