Skip to content

Commit 42de9ae

Browse files
committed
Add yamlling workflow
Signed-off-by: smoshiur1237 <[email protected]>
1 parent de0b2d0 commit 42de9ae

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

.github/workflows/yamllint.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: yamllint
3+
on:
4+
pull_request:
5+
types: [ opened, edited, synchronize, reopened ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Install yamllint
15+
run: sudo apt-get update && sudo apt-get install -y yamllint
16+
17+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
18+
19+
- name: Extract YAML snippets from md files
20+
run: |
21+
set -euo pipefail
22+
mkdir -p .yaml-snippet
23+
24+
# Process each md file
25+
while IFS= read -r md_file; do
26+
echo "Processing: ${md_file}"
27+
28+
# Get safe filename based on full path
29+
safe_name=$(echo "${md_file}" | sed 's/[\/\.]/_/g')
30+
31+
# Extract YAML code blocks and save each one
32+
awk -v base="${safe_name}" '
33+
BEGIN { count=0 }
34+
/^```(yaml|yml)/ { in_block=1; next }
35+
/^```/ && in_block {
36+
if (block != "") {
37+
count++
38+
file = sprintf(".yaml-snippet/%s_snippet_%03d.yaml", base, count)
39+
print block > file
40+
close(file)
41+
block = ""
42+
}
43+
in_block=0
44+
next
45+
}
46+
in_block { block = (block == "" ? $0 : block "\n" $0) }
47+
' "${md_file}"
48+
done < <(find . -name "*.md" -not -path "./.git/*")
49+
50+
echo "Extracted $(ls -1 .yaml-snippet/*.yaml 2>/dev/null | wc -l) YAML snippet(s)"
51+
- name: yaml-lint
52+
uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1
53+
with:
54+
config_file: .yamllint.yaml
55+
56+
- name: yaml-lint for md snippets
57+
uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1
58+
with:
59+
config_file: .yamllint.yaml
60+
file_or_dir: .yaml-snippet/
61+
strict: true

.yamllint.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
yaml-files:
2+
- '*.yaml'
3+
- '*.yml'
4+
- '.yamllint'
5+
6+
rules:
7+
trailing-spaces: enable
8+
key-duplicates: enable
9+
indentation:
10+
spaces: 2
11+
indent-sequences: false # Enforce k8s-style indentation
12+
check-multi-line-strings: false
13+
truthy:
14+
allowed-values: [ 'true', 'false', 'yes', 'no', 'on' ]

0 commit comments

Comments
 (0)