Skip to content

Commit 0280259

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

14 files changed

Lines changed: 195 additions & 535 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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: Create Pull Request
37+
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2
38+
with:
39+
commit-message: "chore: update external content modules"
40+
title: "Update external content modules"
41+
body: |
42+
This PR updates the Hugo modules to pull the latest content from upstream repositories.
43+
44+
This is an automated update. Prow will merge it after CI passes.
45+
46+
/sig contributor-experience
47+
/kind feature
48+
/lgtm
49+
/approve
50+
51+
Triggered by: ${{ github.event_name }}
52+
branch: "automation/update-modules"
53+
base: "master"
54+
labels: "kind/feature, sig/contributor-experience, tide/merge-method-squash"

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ 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 ./

Makefile

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,33 @@ 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)
2222
CONTAINER_RUN := $(CONTAINER_ENGINE) run --rm -it -v "$(CURDIR):/src"
2323
CONTAINER_RUN_TTY := $(CONTAINER_ENGINE) run --rm -it
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 \
4043
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
4144
--mount type=bind,source=$(CURDIR)/hugo.yaml,target=/src/hugo.yaml,readonly
4245

43-
# Fast NONBLOCKING IO to stdout caused by the hack/gen-content.sh script can
46+
# Fast NONBLOCKING IO to stdout caused by Hugo module operations can
4447
# cause Netlify builds to terminate unexpectedly. This forces stdout to block.
4548
BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
4649
flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); \
@@ -49,17 +52,21 @@ BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
4952
.DEFAULT_GOAL := help
5053

5154
.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
55+
targets: help modules-get render server clean clean-all production-build preview-build
56+
container-targets: container-image container-push container-modules-get container-render container-server
5457

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

5861
dependencies:
5962
npm ci
6063

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

6471
render: dependencies ## Build the site using Hugo on the host.
6572
hugo --logLevel info --ignoreCache --minify
@@ -77,7 +84,7 @@ docker-image:
7784
$(MAKE) container-image
7885

7986
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)
87+
$(CONTAINER_ENGINE) build . -t $(CONTAINER_IMAGE) --label git_commit=$(COMMIT) --build-arg HUGO_VERSION=$(HUGO_VERSION) --build-arg GO_VERSION=$(GO_VERSION)
8188

8289
container-push: container-image ## Push container image for the preview of the website
8390
$(CONTAINER_ENGINE) push $(CONTAINER_IMAGE)
@@ -94,24 +101,25 @@ docker-push: ## Build a multi-architecture image and push that into the registry
94101
--push \
95102
--platform=$(PLATFORMS) \
96103
--build-arg HUGO_VERSION=$(HUGO_VERSION) \
104+
--build-arg GO_VERSION=$(GO_VERSION) \
97105
--tag $(CONTAINER_IMAGE) \
98106
-f Dockerfile.cross .
99107
$(DOCKER_BUILDX) stop image-builder
100108
rm Dockerfile.cross
101109

102110
docker-gen-content:
103111
@echo -e "**** The use of docker-gen-content is deprecated. Use container-gen-content instead. ****" 1>&2
104-
$(MAKE) container-gen-content
112+
$(MAKE) container-modules-get
105113

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
114+
container-modules-get: ## Pulls latest Hugo module content within a container.
115+
$(CONTAINER_RUN) -e GOMODCACHE=/tmp/gomod $(CONTAINER_IMAGE) hugo mod get -u
108116

109117
docker-render:
110118
@echo -e "**** The use of docker-render is deprecated. Use container-render instead. ****" 1>&2
111119
$(MAKE) container-render
112120

113121
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
122+
$(CONTAINER_RUN_TTY) $(CONTAINER_HUGO_MOUNTS) -e GOMODCACHE=/tmp/gomod $(CONTAINER_IMAGE) hugo --logLevel info --ignoreCache --minify
115123

116124
docker-server:
117125
@echo -e "**** The use of docker-server is deprecated. Use container-server instead. ****" 1>&2
@@ -123,9 +131,9 @@ container-server: ## Run Hugo locally within a container, available at http://lo
123131
$(CONTAINER_HUGO_MOUNTS) \
124132
--cap-drop=ALL \
125133
--cap-drop=AUDIT_WRITE \
134+
-e GOMODCACHE=/tmp/gomod \
126135
$(CONTAINER_IMAGE) \
127-
bash -c 'cd /src && hack/gen-content.sh --in-container && \
128-
cd /tmp/src && \
136+
bash -c 'cd /src && hugo mod get -u && \
129137
hugo server \
130138
--environment preview \
131139
--logLevel info \
@@ -141,40 +149,12 @@ container-server: ## Run Hugo locally within a container, available at http://lo
141149
clean: ## Cleans build artifacts.
142150
rm -rf public/ resources/ _tmp/
143151

144-
clean-all: ## Cleans both build artifacts and files synced to content directory
152+
clean-all: ## Cleans both build artifacts and Hugo cache.
145153
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 {} \;
154+
hugo mod clean
174155

175156
production-build: ## Builds the production site (this command used only by Netlify).
176157
$(BLOCK_STDOUT_CMD)
177-
hack/gen-content.sh
178158
hugo \
179159
--environment production \
180160
--logLevel info \
@@ -183,7 +163,6 @@ production-build: ## Builds the production site (this command used only by Netli
183163

184164
preview-build: ## Builds a deploy preview of the site (this command used only by Netlify).
185165
$(BLOCK_STDOUT_CMD)
186-
hack/gen-content.sh
187166
hugo \
188167
--environment preview \
189168
--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.

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/kubernetes/contributor-site
2+
3+
go 1.26
4+
5+
require (
6+
github.com/cncf/foundation v0.0.0-20260430214659-243fa9e01436 // indirect
7+
k8s.io/community v0.0.0-20260430184724-b0a07ba82a52 // indirect
8+
k8s.io/sig-release v0.0.0-20260422172754-760d54e82b76 // indirect
9+
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
github.com/cncf/foundation v0.0.0-20260430214659-243fa9e01436 h1:owe4PR/Vx3ONFeP/DkST+aT/BFs/fRLo6CyMONdU1dY=
2+
github.com/cncf/foundation v0.0.0-20260430214659-243fa9e01436/go.mod h1:Bc+TWRzbCv6T+tkQqNuwGA3cGk017o2TE5CAmu9EY/Q=
3+
k8s.io/community v0.0.0-20260430184724-b0a07ba82a52 h1:SzUz4T5TP9OqTKt79H7tMhcw3cFXn2gLfzopZLZTFGE=
4+
k8s.io/community v0.0.0-20260430184724-b0a07ba82a52/go.mod h1:xtSUbAS2+b+VSyXBArm0L8NyzxCRQnrZj1PrFq2v1Zw=
5+
k8s.io/sig-release v0.0.0-20260422172754-760d54e82b76 h1:lbf1F+UCK+rfAf47wQeQ5Uoa4BNX2vRUUcKuiB+2Qk0=
6+
k8s.io/sig-release v0.0.0-20260422172754-760d54e82b76/go.mod h1:QjF+jIUa1Uy3JUvF/cJg1OtfuiLLurUpIfz2AKg2874=

0 commit comments

Comments
 (0)