-
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (75 loc) · 3.27 KB
/
Copy pathpages.yml
File metadata and controls
85 lines (75 loc) · 3.27 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Pages
# Publishes /docs, which is not moved or copied to do it — site/hugo.yaml
# mounts that directory. So this workflow adds a second rendering of the same
# files rather than a second set of files, and a docs edit cannot land in one
# place and not the other.
#
# Pull requests build but do not deploy: the build is the check that a docs
# edit did not break the site, and a fork should not be able to publish.
on:
push:
branches: [main]
paths: ['docs/**', 'site/**', '.github/workflows/pages.yml']
pull_request:
branches: [main]
paths: ['docs/**', 'site/**', '.github/workflows/pages.yml']
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # checkout v7.0.1
# Only on the deploy path. This step asks the API for the configured
# Pages site, which 404s until Pages is switched on in repository
# settings — and a pull request that only wants to know whether the site
# still builds should not fail on a setting it cannot see or change.
- name: Configure GitHub Pages
id: pages
if: github.event_name != 'pull_request'
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # configure-pages v6.0.0
- name: Install Hugo
env:
# Must be >= 0.158: site/hugo.yaml uses `locale`, which older
# versions do not know, and `renderHooks.link.useEmbedded`, which
# replaced `enableDefault` in 0.148. Pinning an older Hugo here would
# build a site whose cross-document links silently 404.
HUGO_VERSION: 0.164.0
run: |
curl -sSLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir -p "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_${HUGO_VERSION}_linux-amd64.tar.gz"
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
# --baseURL falls back to the one in site/hugo.yaml on a pull request,
# where the previous step did not run. The rendered URLs are then only
# right for the real site, which is exactly what a build check needs.
# `hugo` exits non-zero on a template or config error, so this step is
# the check.
- name: Build the site
run: |
hugo \
--source site \
--destination "${{ github.workspace }}/site/public" \
--gc --minify \
${{ steps.pages.outputs.base_url && format('--baseURL "{0}/"', steps.pages.outputs.base_url) || '' }} \
--cacheDir "${{ runner.temp }}/hugo_cache"
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # upload-pages-artifact v5.0.0
if: github.event_name != 'pull_request'
with:
path: site/public
deploy:
if: github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # deploy-pages v5.0.0