-
Notifications
You must be signed in to change notification settings - Fork 48
70 lines (59 loc) · 1.97 KB
/
build_pr_preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
name: Build pull request preview
# Setup and build files with hugo
# https://github.com/peaceiris/actions-hugo
on:
pull_request:
# Run when label is added or present and when pushing to the PR
types: [labeled, opened, synchronize]
permissions:
contents: write
jobs:
build_preview:
# Do not run on forks, and only if "safe for preview" label is set
if: >
((github.event.action == 'labeled' && github.event.label.name == 'safe for
preview') || (github.event.action != 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'safe for preview')))
name: Build with Hugo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Fetch the Docsy theme
submodules: recursive
# Fetch all history for .GitInfo and .Lastmod
fetch-depth: 0
- name: Get Hugo version
id: hugo_version
uses: juliangruber/read-file-action@v1
with:
path: .github/workflows/hugo_version.txt
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "${{ steps.hugo_version.outputs.content }}"
extended: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm project with a clean slate
run: npm ci
- name: Build and minify using Hugo
# Build in a directory specific to the PR number
run: hugo --minify --destination public/${{ github.event.number }}
- name: Save PR number
run: echo ${{ github.event.number }} > ./public/PR
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: pr
path: public/