Skip to content

Commit 33d30a5

Browse files
committed
Add markdownlint CI for blog posts
1 parent 30c23f7 commit 33d30a5

6 files changed

Lines changed: 1292 additions & 72 deletions

File tree

.github/workflows/verify-blog.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Verify blog posts
2+
on:
3+
pull_request:
4+
paths:
5+
- 'content/*/blog/**/*.md'
6+
jobs:
7+
markdownlint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
14+
with:
15+
node-version: '20'
16+
- run: npm ci
17+
- run: make lint-blogs BASE_REF=${{ github.base_ref }}

.markdownlint.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD033": false,
5+
"MD041": false,
6+
"MD024": false,
7+
"MD046": false
8+
}

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
4949
.DEFAULT_GOAL := help
5050

5151
.PHONY: targets container-targets
52-
targets: help gen-content render server clean clean-all production-build preview-build
52+
targets: help gen-content render server lint-blogs clean clean-all production-build preview-build
5353
container-targets: container-image container-push container-gen-content container-render container-server
5454

5555
help: ## Show this help text.
@@ -58,6 +58,9 @@ help: ## Show this help text.
5858
dependencies:
5959
npm ci
6060

61+
lint-blogs: ## Run markdownlint on changed blog posts.
62+
hack/lint-blogs.sh $(BASE_REF)
63+
6164
gen-content: ## Generates content from external sources.
6265
hack/gen-content.sh
6366

hack/lint-blogs.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2026 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
set -o nounset
18+
19+
BASE_REF="${1:-main}"
20+
21+
CHANGED=$(git diff --name-only "origin/${BASE_REF}...HEAD" -- 'content/*/blog/*.md')
22+
23+
if [ -z "${CHANGED}" ]; then
24+
echo "No blog files changed."
25+
exit 0
26+
fi
27+
28+
echo "Linting blog files changed against ${BASE_REF}..."
29+
echo "${CHANGED}" | xargs markdownlint --config .markdownlint.json

0 commit comments

Comments
 (0)