Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ on:
branches: [main]
workflow_dispatch:

# Allow the workflow to write to GitHub Pages
# Write access to push the built site to the gh-pages branch
permissions:
contents: read
pages: write
id-token: write
contents: write

# Only allow one deployment at a time; don't cancel in-progress runs
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Expand All @@ -41,18 +39,9 @@ jobs:
# hugo.toml sets minifyOutput = false because Hugo's minifier
# breaks PaperMod's JSON-LD schema output.

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
path: site/public

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site/public
publish_branch: gh-pages
40 changes: 40 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PR Preview

on:
pull_request:
types: [opened, synchronize, reopened, closed]

# Write to gh-pages branch and post comments on the PR
permissions:
contents: write
pull-requests: write

jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
fetch-depth: 0

- name: Setup Hugo
if: github.event.action != 'closed'
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.155.3'
extended: true

- name: Build preview
if: github.event.action != 'closed'
# -D includes drafts so in-progress posts are visible in the preview
run: hugo --source site --baseURL "https://mathieson.github.io/blog/pr-preview/pr-${{ github.event.number }}/" -D

- name: Deploy / remove preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: site/public
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
token: ${{ secrets.GITHUB_TOKEN }}
Loading