Skip to content

Commit 7f79b21

Browse files
committed
feat(ci): enusure docs are up-to-date for PRs
relates to STACKITCLI-131
1 parent c166bac commit 7f79b21

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ relates to #1234
1212
- [ ] Issue was linked above
1313
- [ ] Code format was applied: `make fmt`
1414
- [ ] Examples were added / adjusted (see e.g. [here](https://github.com/stackitcloud/stackit-cli/blob/ef291d1683ca5b0d719ec0a26ecb999a32685117/internal/cmd/ske/cluster/create/create.go#L49-L63))
15-
- [ ] Docs are up-to-date: `make generate-docs`
15+
- [ ] Docs are up-to-date: `make generate-docs` (will be checked by CI)
1616
- [ ] Unit tests got implemented or updated
1717
- [x] Unit tests are passing: `make test` (will be checked by CI)
1818
- [x] No linter issues: `make lint` (will be checked by CI)

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v4
15+
1516
- name: Build
1617
uses: ./.github/actions/build
1718
with:
1819
go-version: ${{ env.GO_VERSION }}
20+
21+
- name: "Ensure docs are up-to-date"
22+
if: ${{ github.event_name == 'pull_request' }}
23+
run: ./scripts/check-docs.sh
24+
1925
- name: Lint
2026
run: make lint
27+
2128
- name: Test
2229
run: make test

scripts/check-docs.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# This script is used to ensure for PRs the docs are up-to-date via the CI pipeline
4+
# Usage: ./check-docs.sh
5+
set -eo pipefail
6+
7+
ROOT_DIR=$(git rev-parse --show-toplevel)
8+
9+
before_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
10+
11+
# re-generate the docs
12+
go run $ROOT_DIR/scripts/generate.go
13+
14+
after_hash=$(find docs -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}')
15+
16+
if [[ "$before_hash" == "$after_hash" ]]; then
17+
echo "Docs are up-to-date"
18+
else
19+
echo "Changes detected. Docs are *not* up-to-date."
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)