Skip to content

Commit f9ec0d8

Browse files
committed
feat: migrate content ingestion to Hugo Modules and Go 1.26
1 parent 1593f5c commit f9ec0d8

19 files changed

Lines changed: 348 additions & 556 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Update Content Modules
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 1' # Every Monday at midnight
6+
workflow_dispatch: # Allow manual trigger
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update-modules:
14+
runs-on: ubuntu-latest
15+
if: github.repository == 'kubernetes/contributor-site'
16+
steps:
17+
- name: Check out repository code
18+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
19+
20+
- name: Setup Go
21+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
22+
with:
23+
go-version: '1.26.2'
24+
25+
- name: Setup Hugo
26+
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
27+
with:
28+
hugo-version: '0.133.0'
29+
extended: true
30+
31+
- name: Update Hugo Modules
32+
run: |
33+
hugo mod get -u
34+
hugo mod tidy
35+
36+
- name: Run Content & Image Tests (Container)
37+
run: make container-test
38+
39+
- name: Create Pull Request
40+
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2
41+
with:
42+
commit-message: "chore: update external content modules"
43+
title: "Update external content modules"
44+
body: |
45+
This PR updates the Hugo modules to pull the latest content from upstream repositories.
46+
47+
This is an automated update. Prow will merge it after CI passes.
48+
49+
/sig contributor-experience
50+
/kind feature
51+
/lgtm
52+
/approve
53+
54+
Triggered by: ${{ github.event_name }}
55+
branch: "automation/update-modules"
56+
base: "master"
57+
labels: "kind/feature, sig/contributor-experience, tide/merge-method-squash"

.github/workflows/verify.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Verify PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
verify:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out repository code
16+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
17+
18+
- name: Run Content & Image Tests (Container)
19+
run: |
20+
# The Makefile will automatically build the image using the local Dockerfile
21+
# which contains all necessary dependencies (Go 1.26, Hugo, Python, etc.)
22+
make container-test

.htmltest.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DirectoryPath: public
2+
CheckInternalLinks: true
3+
CheckInternalHashes: true
4+
CheckExternalLinks: false # Disabled to keep CI fast and stable
5+
CheckImages: true
6+
CheckAlt: true
7+
IgnoreURLs:
8+
- "https://slack.k8s.io" # Often rate-limited
9+
IgnoreDirs:
10+
- google_analytics
11+
- reveal
12+
LogFile: htmltest.log
13+
LogLevel: 2

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,27 @@ RUN apk add --no-cache \
1717
sed \
1818
npm
1919

20+
# Install Go
21+
ARG GO_VERSION=1.26.2
22+
RUN curl -sSfL "https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz" -o /tmp/go.tgz \
23+
&& tar -xz -C /usr/local -f /tmp/go.tgz \
24+
&& rm /tmp/go.tgz
25+
ENV PATH="/usr/local/go/bin:${PATH}"
26+
2027
WORKDIR /src
2128

2229
COPY package*.json ./
2330

2431
RUN npm ci --ignore-scripts
2532

33+
RUN apk add --no-cache python3 py3-pip
34+
RUN pip3 install --break-system-packages pyyaml
35+
2636
RUN mkdir -p /usr/local/src && \
2737
cd /usr/local/src && \
2838
curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz | tar -xz && \
2939
mv hugo /usr/local/bin/hugo && \
40+
curl -sL https://htmltest.wjdp.uk | bash -s -- -b /usr/local/bin && \
3041
addgroup -Sg 1000 hugo && \
3142
adduser -Sg hugo -u 1000 -h /src hugo
3243

Makefile

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,34 @@ STAGING_IMAGE_REGISTRY := us-central1-docker.pkg.dev/k8s-staging-images
1717
IMAGE_REGISTRY ?= ${STAGING_IMAGE_REGISTRY}/contributor-site
1818
IMAGE_NAME := k8s-contrib-site-hugo
1919
IMAGE_REPO := $(IMAGE_REGISTRY)/$(IMAGE_NAME)
20-
IMAGE_VERSION := $(shell scripts/hash-files.sh Dockerfile Makefile netlify.toml .dockerignore cloudbuild.yaml package.json package-lock.json | cut -c 1-12)
20+
IMAGE_VERSION := $(shell scripts/hash-files.sh Dockerfile Makefile netlify.toml .dockerignore cloudbuild.yaml package.json package-lock.json go.mod go.sum | cut -c 1-12)
2121
COMMIT := $(shell git rev-parse --short HEAD)
22-
CONTAINER_RUN := $(CONTAINER_ENGINE) run --rm -it -v "$(CURDIR):/src"
23-
CONTAINER_RUN_TTY := $(CONTAINER_ENGINE) run --rm -it
22+
CONTAINER_RUN := $(CONTAINER_ENGINE) run --rm -v "$(CURDIR):/src"
23+
CONTAINER_RUN_TTY := $(CONTAINER_ENGINE) run --rm
2424
HUGO_VERSION := $(shell grep ^HUGO_VERSION netlify.toml | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
25+
GO_VERSION := $(shell grep ^GO_VERSION netlify.toml | tail -n 1 | cut -d '=' -f 2 | tr -d " \"\n")
2526
GIT_TAG ?= v$(HUGO_VERSION)-$(IMAGE_VERSION)
2627
CONTAINER_IMAGE := $(IMAGE_REPO):$(GIT_TAG)
28+
GOMODCACHE ?= $(shell go env GOMODCACHE)
2729

2830
# Docker buildx related settings for multi-arch images
2931
DOCKER_BUILDX ?= docker buildx
3032

3133
CONTAINER_HUGO_MOUNTS = \
3234
--read-only \
3335
--mount type=bind,source=$(CURDIR)/.git,target=/src/.git,readonly \
36+
--mount type=bind,source=$(CURDIR)/go.mod,target=/src/go.mod \
37+
--mount type=bind,source=$(CURDIR)/go.sum,target=/src/go.sum \
38+
--mount type=bind,source=$(GOMODCACHE),target=/tmp/gomod \
3439
--mount type=bind,source=$(CURDIR)/assets,target=/src/assets,readonly \
3540
--mount type=bind,source=$(CURDIR)/content,target=/src/content,readonly \
36-
--mount type=bind,source=$(CURDIR)/external-sources,target=/src/external-sources,readonly \
37-
--mount type=bind,source=$(CURDIR)/hack,target=/src/hack,readonly \
3841
--mount type=bind,source=$(CURDIR)/layouts,target=/src/layouts,readonly \
3942
--mount type=bind,source=$(CURDIR)/static,target=/src/static,readonly \
43+
--mount type=bind,source=$(CURDIR)/scripts,target=/src/scripts,readonly \
4044
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
4145
--mount type=bind,source=$(CURDIR)/hugo.yaml,target=/src/hugo.yaml,readonly
4246

43-
# Fast NONBLOCKING IO to stdout caused by the hack/gen-content.sh script can
47+
# Fast NONBLOCKING IO to stdout caused by Hugo module operations can
4448
# cause Netlify builds to terminate unexpectedly. This forces stdout to block.
4549
BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
4650
flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); \
@@ -49,21 +53,36 @@ BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
4953
.DEFAULT_GOAL := help
5054

5155
.PHONY: targets container-targets
52-
targets: help gen-content render server clean clean-all production-build preview-build
53-
container-targets: container-image container-push container-gen-content container-render container-server
56+
targets: help modules-get render server test clean clean-all production-build preview-build
57+
container-targets: container-image container-push container-modules-get container-render container-server container-test
5458

5559
help: ## Show this help text.
5660
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
5761

5862
dependencies:
5963
npm ci
64+
pip3 install pyyaml || echo "Warning: pip3 install failed, verify-mounts.py may fail."
6065

61-
gen-content: ## Generates content from external sources.
62-
hack/gen-content.sh
66+
modules-get: ## Pulls latest Hugo module content.
67+
hugo mod get -u
68+
hugo mod tidy
69+
70+
modules-tidy: ## Clean and tidy Hugo modules.
71+
hugo mod tidy
6372

6473
render: dependencies ## Build the site using Hugo on the host.
6574
hugo --logLevel info --ignoreCache --minify
6675

76+
test: render ## Run content verification and link/image checks.
77+
python3 scripts/verify-mounts.py --config hugo.yaml --public public
78+
if ! command -v htmltest >/dev/null; then curl -sL https://htmltest.wjdp.uk | bash; ./bin/htmltest; else htmltest; fi
79+
80+
container-test: container-image ## Run tests within a container using pre-installed dependencies.
81+
$(CONTAINER_RUN_TTY) $(CONTAINER_HUGO_MOUNTS) -e GOMODCACHE=/tmp/gomod $(CONTAINER_IMAGE) \
82+
bash -c "hugo --ignoreCache --minify --destination /tmp/public && \
83+
python3 scripts/verify-mounts.py --config hugo.yaml --public /tmp/public && \
84+
htmltest --conf .htmltest.yml /tmp/public"
85+
6786
server: dependencies ## Run Hugo locally (if Hugo "extended" is installed locally)
6887
hugo server \
6988
--logLevel info \
@@ -77,7 +96,7 @@ docker-image:
7796
$(MAKE) container-image
7897

7998
container-image: ## Build container image for use with container-* targets.
80-
$(CONTAINER_ENGINE) build . -t $(CONTAINER_IMAGE) --label git_commit=$(COMMIT) --build-arg HUGO_VERSION=$(HUGO_VERSION)
99+
$(CONTAINER_ENGINE) build . -t $(CONTAINER_IMAGE) --label git_commit=$(COMMIT) --build-arg HUGO_VERSION=$(HUGO_VERSION) --build-arg GO_VERSION=$(GO_VERSION)
81100

82101
container-push: container-image ## Push container image for the preview of the website
83102
$(CONTAINER_ENGINE) push $(CONTAINER_IMAGE)
@@ -94,24 +113,25 @@ docker-push: ## Build a multi-architecture image and push that into the registry
94113
--push \
95114
--platform=$(PLATFORMS) \
96115
--build-arg HUGO_VERSION=$(HUGO_VERSION) \
116+
--build-arg GO_VERSION=$(GO_VERSION) \
97117
--tag $(CONTAINER_IMAGE) \
98118
-f Dockerfile.cross .
99119
$(DOCKER_BUILDX) stop image-builder
100120
rm Dockerfile.cross
101121

102122
docker-gen-content:
103123
@echo -e "**** The use of docker-gen-content is deprecated. Use container-gen-content instead. ****" 1>&2
104-
$(MAKE) container-gen-content
124+
$(MAKE) container-modules-get
105125

106-
container-gen-content: ## Generates content from external sources within a container (equiv to gen-content).
107-
$(CONTAINER_RUN) $(CONTAINER_IMAGE) hack/gen-content.sh
126+
container-modules-get: ## Pulls latest Hugo module content within a container.
127+
$(CONTAINER_RUN) -e GOMODCACHE=/tmp/gomod $(CONTAINER_IMAGE) hugo mod get -u
108128

109129
docker-render:
110130
@echo -e "**** The use of docker-render is deprecated. Use container-render instead. ****" 1>&2
111131
$(MAKE) container-render
112132

113133
container-render: ## Build the site using Hugo within a container (equiv to render).
114-
$(CONTAINER_RUN_TTY) $(CONTAINER_HUGO_MOUNTS) $(CONTAINER_IMAGE) hugo --logLevel info --ignoreCache --minify
134+
$(CONTAINER_RUN_TTY) $(CONTAINER_HUGO_MOUNTS) -e GOMODCACHE=/tmp/gomod $(CONTAINER_IMAGE) hugo --logLevel info --ignoreCache --minify
115135

116136
docker-server:
117137
@echo -e "**** The use of docker-server is deprecated. Use container-server instead. ****" 1>&2
@@ -123,9 +143,9 @@ container-server: ## Run Hugo locally within a container, available at http://lo
123143
$(CONTAINER_HUGO_MOUNTS) \
124144
--cap-drop=ALL \
125145
--cap-drop=AUDIT_WRITE \
146+
-e GOMODCACHE=/tmp/gomod \
126147
$(CONTAINER_IMAGE) \
127-
bash -c 'cd /src && hack/gen-content.sh --in-container && \
128-
cd /tmp/src && \
148+
bash -c 'cd /src && hugo mod get -u && \
129149
hugo server \
130150
--environment preview \
131151
--logLevel info \
@@ -141,40 +161,12 @@ container-server: ## Run Hugo locally within a container, available at http://lo
141161
clean: ## Cleans build artifacts.
142162
rm -rf public/ resources/ _tmp/
143163

144-
clean-all: ## Cleans both build artifacts and files synced to content directory
164+
clean-all: ## Cleans both build artifacts and Hugo cache.
145165
rm -rf public/ resources/ _tmp/
146-
rm -f content/en/events/community-meeting.md
147-
rm -f content/en/events/meet-our-contributors.md
148-
rm -f content/en/events/office-hours.md
149-
rm -f content/en/docs/cheatsheet.md
150-
rm -f content/en/resources/rename.md
151-
find content/en/docs/guide -maxdepth 1 \
152-
-not -path content/en/docs/guide \
153-
-not -name ".gitignore" \
154-
-exec rm -rf {} \;
155-
find content/en/docs/comms -maxdepth 1 \
156-
-not -path content/en/docs/comms \
157-
-not -name ".gitignore" \
158-
-not -name "_index.md" \
159-
-exec rm -rf {} \;
160-
find content/en/resources/release -maxdepth 1 \
161-
-not -path content/en/resources/release \
162-
-not -name ".gitignore" \
163-
-exec rm -rf {} \;
164-
find content/en/docs/orientation -maxdepth 1 \
165-
-not -path content/en/docs/orientation \
166-
-not -name ".gitignore" \
167-
-exec rm -rf {} \;
168-
find content/en/community -maxdepth 1 \
169-
-not -path content/en/community \
170-
-not -name ".gitignore" \
171-
-not -name "_index.md" \
172-
-not -name "code-of-conduct.md" \
173-
-exec rm -rf {} \;
166+
hugo mod clean
174167

175168
production-build: ## Builds the production site (this command used only by Netlify).
176169
$(BLOCK_STDOUT_CMD)
177-
hack/gen-content.sh
178170
hugo \
179171
--environment production \
180172
--logLevel info \
@@ -183,7 +175,6 @@ production-build: ## Builds the production site (this command used only by Netli
183175

184176
preview-build: ## Builds a deploy preview of the site (this command used only by Netlify).
185177
$(BLOCK_STDOUT_CMD)
186-
hack/gen-content.sh
187178
hugo \
188179
--environment preview \
189180
--logLevel info \

README.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Site is to use [Docker][docker]. To begin, create the docker image to be used
4343
with generating the site by executing `make container-image`.
4444

4545
To ensure you can view the site with externally sourced content, run
46-
`make container-gen-content` before previewing the site by with
46+
`make container-modules-get` before previewing the site with
4747
`make container-server`.
4848

4949
**NOTE to Apple Silicon Mac Users**
@@ -73,22 +73,7 @@ git submodule update --init --recursive --depth 1
7373
```
7474

7575
To ensure you can view the site with externally sourced content, run
76-
`make gen-content` before previewing the site by with `make server`.
77-
78-
**NOTE to MacOS Users**
79-
80-
The `hack/gen-content.sh` script requires the gnu version
81-
of base packages such as `find`, `grep`, and `sed`.
82-
83-
```
84-
brew install coreutils findutils grep gnu-sed gnu-tar make readlink
85-
```
86-
87-
You will then need to update your path to include these:
88-
89-
```
90-
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
91-
```
76+
`make modules-get` before previewing the site with `make server`.
9277

9378
## Community, discussion, contribution, and support
9479

content/en/includes/_index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
---
22
headless: true
3-
_build:
4-
list: never
5-
render: false
63
---

external-sources/cncf/foundation

Lines changed: 0 additions & 1 deletion
This file was deleted.

external-sources/kubernetes/community

Lines changed: 0 additions & 36 deletions
This file was deleted.

external-sources/kubernetes/sig-release

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)