Skip to content

Commit d56a2d4

Browse files
micheleRPclaude
andauthored
ci: add playbook branch validation check (#552)
* ci: add playbook branch check to prevent merging with PR branches Adds a CI workflow that checks local-antora-playbook.yml for non-standard branch references. Fails if any branch value doesn't match the allowed set (main, HEAD, v/*, shared, site-search, etc.). This prevents accidentally merging a playbook that still points to a PR branch instead of main, which would break the production build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use POSIX [[:space:]] instead of \s in sed for consistency Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d9b4db7 commit d56a2d4

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: Check playbook branches
3+
on:
4+
pull_request:
5+
paths:
6+
- local-antora-playbook.yml
7+
push:
8+
branches: [main]
9+
paths:
10+
- local-antora-playbook.yml
11+
12+
jobs:
13+
check-branches:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Check for non-standard branch references
19+
run: |
20+
# Allowed branch patterns in local-antora-playbook.yml.
21+
# Any value not matching these is likely a PR branch that
22+
# must be reverted before merge.
23+
ALLOWED='main|HEAD|v/\*|shared|site-search|!v-end-of-life/\*'
24+
25+
# Extract all branch values from the playbook
26+
BRANCHES=$(grep 'branches:' local-antora-playbook.yml \
27+
| sed 's/.*branches:[[:space:]]*//' \
28+
| tr -d "[]'" \
29+
| tr ',' '\n' \
30+
| sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
31+
32+
FAILED=0
33+
while IFS= read -r branch; do
34+
[ -z "$branch" ] && continue
35+
if ! echo "$branch" | grep -qE "^(${ALLOWED})$"; then
36+
echo "::error::Non-standard branch reference found: '${branch}'"
37+
FAILED=1
38+
fi
39+
done <<< "$BRANCHES"
40+
41+
if [ "$FAILED" -eq 1 ]; then
42+
echo ""
43+
echo "local-antora-playbook.yml contains non-standard branch references."
44+
echo "These are used for cross-repo Netlify previews during PR development,"
45+
echo "but must be reverted to standard values (e.g., 'main') before merging."
46+
exit 1
47+
fi
48+
49+
echo "Playbook OK: all branch references are standard."

0 commit comments

Comments
 (0)