-
-
Notifications
You must be signed in to change notification settings - Fork 28
52 lines (48 loc) · 1.39 KB
/
validate_yamllint.yml
File metadata and controls
52 lines (48 loc) · 1.39 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
50
51
52
---
name: Validate YAML (secondary files)
# yamllint disable-line rule:truthy
on:
push:
paths:
- '**/*.yml'
- '**/*.yaml'
pull_request:
paths:
- '**/*.yml'
- '**/*.yaml'
workflow_dispatch:
jobs:
code_scan:
name: Validate YAML
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensures full commit history for diff
- name: Identify changed files
id: changed-files
run: |
BASE=${{ github.event.before }}
HEAD=${{ github.sha }}
FILES=$(git diff --name-only $BASE $HEAD -- '**/*.yml' '**/*.yaml' | tr '\n' ',')
echo "changed_files=$FILES" >> $GITHUB_ENV
if [[ -n "$FILES" ]]; then
echo "any_changed=true" >> $GITHUB_ENV
else
echo "any_changed=false" >> $GITHUB_ENV
fi
- name: Validate YAML
if: env.any_changed == 'true'
run: |
IFS=',' read -ra FILES <<< "${{ env.changed_files }}"
for file in "${FILES[@]}"; do
if [[ "$file" =~ ^.*\.yaml$ ]] || [[ "$file" =~ ^ESPHome/.*\.yaml$ ]]; then
echo "Skipping $file"
continue
fi
echo "::group::Validating $file"
yamllint -c "./.rules/yamllint.yml" "$file"
echo "::endgroup::"
done
...