Skip to content

Commit 1c387c0

Browse files
authored
Merge pull request #3962 from Blargian/badger
Add "badger" to notify current badge status
2 parents be1c6c1 + b11c98a commit 1c387c0

File tree

3 files changed

+138
-16
lines changed

3 files changed

+138
-16
lines changed

.github/workflows/badges-notify.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Weekly Badge Monitor
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 10:00 AM Amsterdam time (UTC+1/+2)
6+
# Using 8:00 UTC to account for Amsterdam time (adjusts for DST)
7+
- cron: '0 8 * * 1'
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
monitor-badges:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Make script executable
19+
run: chmod +x scripts/badger.sh
20+
21+
- name: Run badge finder script
22+
id: find_badges
23+
run: |
24+
# Run the script and capture output
25+
SCRIPT_OUTPUT=$(scripts/badger.sh)
26+
27+
# Escape the output for JSON and store in GitHub output
28+
# Replace newlines with \n and escape quotes
29+
ESCAPED_OUTPUT=$(echo "$SCRIPT_OUTPUT" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
30+
31+
echo "badges_output<<EOF" >> $GITHUB_OUTPUT
32+
echo "$ESCAPED_OUTPUT" >> $GITHUB_OUTPUT
33+
echo "EOF" >> $GITHUB_OUTPUT
34+
35+
- name: Send webhook
36+
env:
37+
WEBHOOK_URL: ${{ secrets.DOCS_BADGER }}
38+
BADGES_OUTPUT: ${{ steps.find_badges.outputs.badges_output }}
39+
run: |
40+
# Create JSON payload
41+
JSON_PAYLOAD=$(cat <<EOF
42+
{
43+
"badges_list": "$BADGES_OUTPUT"
44+
}
45+
EOF
46+
)
47+
48+
# Send webhook
49+
curl -X POST \
50+
-H "Content-Type: application/json" \
51+
-d "$JSON_PAYLOAD" \
52+
"$WEBHOOK_URL"
53+
54+
- name: Log completion
55+
run: |
56+
echo "Badge monitoring completed successfully"
57+
echo "Webhook sent to configured endpoint"

scripts/badger.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# This script is used to generate a list of feature badges in use in the docs
4+
# It runs as part of a weekly github action and the result is sent as a notification
5+
# to the #docs channel in Slack.
6+
7+
# Default to 'docs' directory if no argument provided
8+
DOCS_DIR="${1:-docs}"
9+
10+
# Check if directory exists
11+
if [ ! -d "$DOCS_DIR" ]; then
12+
echo "Error: Directory '$DOCS_DIR' does not exist"
13+
exit 1
14+
fi
15+
16+
# Components to search for
17+
components=(
18+
"BetaBadge"
19+
"ExperimentalBadge"
20+
"PrivatePreviewBadge"
21+
"CloudNotSupportedBadge"
22+
"CloudAvailableBadge"
23+
)
24+
25+
# Function to extract slug from a file's frontmatter
26+
extract_slug_from_file() {
27+
local filepath="$1"
28+
local slug=""
29+
30+
# Look for "slug: some/path/slug" in the file
31+
slug=$(grep -m 1 "^slug:" "$filepath" 2>/dev/null | sed 's/^slug:[[:space:]]*//' | tr -d '"' | tr -d "'")
32+
33+
# If no slug found, return the filepath as fallback
34+
if [ -z "$slug" ]; then
35+
slug="[no slug] $filepath"
36+
fi
37+
38+
echo "$slug"
39+
}
40+
41+
# Search for each component and collect all slugs
42+
for component in "${components[@]}"; do
43+
echo "$component:"
44+
45+
# Get unique files containing the component
46+
files=$(grep -rl --include="*.md" --include="*.mdx" --include="*.jsx" --include="*.tsx" \
47+
-E "<$component[[:space:]/>]|</$component>" "$DOCS_DIR" 2>/dev/null | sort -u)
48+
49+
if [ -z "$files" ]; then
50+
echo " (none)"
51+
else
52+
while IFS= read -r file; do
53+
if [ -n "$file" ]; then
54+
slug=$(extract_slug_from_file "$file")
55+
if [[ "$slug" == \[no\ slug\]* ]]; then
56+
echo "$slug"
57+
else
58+
echo " • https://clickhouse.com/docs$slug"
59+
fi
60+
fi
61+
done <<< "$files"
62+
fi
63+
64+
echo
65+
done

src/theme/badges/ClickHouseSupported/index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import React from "react"
22
import styles from "./styles.module.css"
33

44
const Icon = () => {
5-
return (
6-
<div className={styles.ClickHouseSupportedIcon} style={{ marginRight: '8px', marginTop: '4px' }}>
7-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
8-
<path d="M1.30762 1.39073C1.30762 1.3103 1.37465 1.22986 1.46849 1.22986H2.64824C2.72868 1.22986 2.80912 1.29689 2.80912 1.39073V14.4886C2.80912 14.5691 2.74209 14.6495 2.64824 14.6495H1.46849C1.38805 14.6495 1.30762 14.5825 1.30762 14.4886V1.39073Z" fill="#282828" />
9-
<path d="M4.2832 1.39073C4.2832 1.3103 4.35023 1.22986 4.44408 1.22986H5.62383C5.70427 1.22986 5.7847 1.29689 5.7847 1.39073V14.4886C5.7847 14.5691 5.71767 14.6495 5.62383 14.6495H4.44408C4.36364 14.6495 4.2832 14.5825 4.2832 14.4886V1.39073Z" fill="#282828" />
10-
<path d="M7.25977 1.39073C7.25977 1.3103 7.3268 1.22986 7.42064 1.22986H8.60039C8.68083 1.22986 8.76127 1.29689 8.76127 1.39073V14.4886C8.76127 14.5691 8.69423 14.6495 8.60039 14.6495H7.42064C7.3402 14.6495 7.25977 14.5825 7.25977 14.4886V1.39073Z" fill="#282828" />
11-
<path d="M10.2354 1.39073C10.2354 1.3103 10.3024 1.22986 10.3962 1.22986H11.576C11.6564 1.22986 11.7369 1.29689 11.7369 1.39073V14.4886C11.7369 14.5691 11.6698 14.6495 11.576 14.6495H10.3962C10.3158 14.6495 10.2354 14.5825 10.2354 14.4886V1.39073Z" fill="#282828" />
12-
<path d="M13.2256 6.6057C13.2256 6.52526 13.2926 6.44482 13.3865 6.44482H14.5662C14.6466 6.44482 14.7271 6.51186 14.7271 6.6057V9.27354C14.7271 9.35398 14.6601 9.43442 14.5662 9.43442H13.3865C13.306 9.43442 13.2256 9.36739 13.2256 9.27354V6.6057Z" fill="#282828" />
13-
</svg>
14-
</div>
15-
)
5+
return (
6+
<div className={styles.ClickHouseSupportedIcon} style={{ marginRight: '8px', marginTop: '4px' }}>
7+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
8+
<path d="M1.30762 1.39073C1.30762 1.3103 1.37465 1.22986 1.46849 1.22986H2.64824C2.72868 1.22986 2.80912 1.29689 2.80912 1.39073V14.4886C2.80912 14.5691 2.74209 14.6495 2.64824 14.6495H1.46849C1.38805 14.6495 1.30762 14.5825 1.30762 14.4886V1.39073Z" fill="#282828" />
9+
<path d="M4.2832 1.39073C4.2832 1.3103 4.35023 1.22986 4.44408 1.22986H5.62383C5.70427 1.22986 5.7847 1.29689 5.7847 1.39073V14.4886C5.7847 14.5691 5.71767 14.6495 5.62383 14.6495H4.44408C4.36364 14.6495 4.2832 14.5825 4.2832 14.4886V1.39073Z" fill="#282828" />
10+
<path d="M7.25977 1.39073C7.25977 1.3103 7.3268 1.22986 7.42064 1.22986H8.60039C8.68083 1.22986 8.76127 1.29689 8.76127 1.39073V14.4886C8.76127 14.5691 8.69423 14.6495 8.60039 14.6495H7.42064C7.3402 14.6495 7.25977 14.5825 7.25977 14.4886V1.39073Z" fill="#282828" />
11+
<path d="M10.2354 1.39073C10.2354 1.3103 10.3024 1.22986 10.3962 1.22986H11.576C11.6564 1.22986 11.7369 1.29689 11.7369 1.39073V14.4886C11.7369 14.5691 11.6698 14.6495 11.576 14.6495H10.3962C10.3158 14.6495 10.2354 14.5825 10.2354 14.4886V1.39073Z" fill="#282828" />
12+
<path d="M13.2256 6.6057C13.2256 6.52526 13.2926 6.44482 13.3865 6.44482H14.5662C14.6466 6.44482 14.7271 6.51186 14.7271 6.6057V9.27354C14.7271 9.35398 14.6601 9.43442 14.5662 9.43442H13.3865C13.306 9.43442 13.2256 9.36739 13.2256 9.27354V6.6057Z" fill="#282828" />
13+
</svg>
14+
</div>
15+
)
1616
}
1717

1818
const ClickHouseSupportedBadge = () => {
19-
return (
20-
<div className={styles.ClickHouseSupportedBadge}>
21-
<Icon />ClickHouse Supported
22-
</div>
23-
)
19+
return (
20+
<div className={styles.ClickHouseSupportedBadge}>
21+
<Icon />ClickHouse Supported
22+
</div>
23+
)
2424
}
2525

2626
export default ClickHouseSupportedBadge

0 commit comments

Comments
 (0)