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