Repository navigation
127 lines (113 loc) · 4.57 KB
/
Copy pathhugo.yml
File metadata and controls
127 lines (113 loc) · 4.57 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Build + deploy the Hugo site to GitHub Pages on every push to main.
# Adapted from the official Hugo template at
# https://gohugo.io/host-and-deploy/host-on-github-pages/.
name: Deploy Hugo site to Pages
on:
push:
branches: [main]
# Build on every pull request too, so a change to the layout, the content or
# the Hugo version has to prove the site still builds before it lands.
# Without this the workflow ran only on main, which meant a dependency bump
# arrived with no signal at all -- its checks read "no checks", which is not
# the same thing as green and must not be merged as if it were.
pull_request:
workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between
# the run in-progress and latest queued. Don't cancel in-progress
# runs — we want them to finish before a new build replaces them.
concurrency:
group: "pages"
cancel-in-progress: false
# The build needs nothing beyond the source and the Pages configuration it
# reads to compute the base URL. Publishing rights are granted to the deploy
# job alone, below, so a pull request build cannot replace what is served.
permissions:
contents: read
pages: read
env:
# Pin Hugo so site builds don't break when a new release ships
# incompatible template changes. Bump deliberately, not by
# surprise.
HUGO_VERSION: 0.135.0
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Hugo CLI
run: |
wget -O hugo.deb "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb"
sudo dpkg -i hugo.deb
- name: Checkout
uses: actions/checkout@v7
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v6
# The playground's three assets are build artifacts, never committed: the
# wasm compiled from playground/ at this commit, the Ruby tab's
# interpreter (go-embedded-ruby at the version playground/rubywasm/go.mod
# pins), and wasm_exec.js taken from the SAME toolchain (all must match).
# Built before Hugo, which reads the two wasm sizes for the progress bars.
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version: "1.27.4"
cache-dependency-path: |
playground/go.sum
playground/rubywasm/go.sum
- name: Build the playground
working-directory: playground
env:
GOWORK: "off"
GOTOOLCHAIN: local
run: |
mkdir -p ../static/playground
GOOS=js GOARCH=wasm go build -trimpath \
-ldflags "-s -w -X main.buildVersion=$(git rev-parse --short HEAD)" \
-o ../static/playground/playground.wasm ./cmd/playground-wasm
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" ../static/playground/
# Fetched by the page only when a visitor opens the Ruby tab.
- name: Build go-embedded-ruby for the Ruby tab
working-directory: playground/rubywasm
env:
GOWORK: "off"
GOTOOLCHAIN: local
run: |
GOOS=js GOARCH=wasm go build -tags rbgo_core -trimpath -ldflags "-s -w" \
-o ../../static/playground/rbgo.wasm github.com/go-embedded-ruby/ruby/cmd/wasm
raw=$(stat -c %s ../../static/playground/rbgo.wasm); gz=$(gzip -9 -c ../../static/playground/rbgo.wasm | wc -c)
echo "rbgo.wasm ($(go list -m -f '{{.Version}}' github.com/go-embedded-ruby/ruby)): $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY"
- name: Build
env:
HUGO_ENVIRONMENT: production
HUGO_ENV: production
# Cache-busts the playground assets: a new deploy is a new URL.
HUGO_PARAMS_WASMSHA: ${{ github.sha }}
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: ./public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
# Only main publishes. A pull request stops after build above: it has built
# the site, which is the whole point of the gate, and it has no business
# replacing what is served.
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5