-
Notifications
You must be signed in to change notification settings - Fork 1.1k
39 lines (33 loc) · 1.58 KB
/
yaml-linting.yml
File metadata and controls
39 lines (33 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
---
name: PUSH & PULL REQUEST - YAML Lint and Schema Validation Checks
on: [push,pull_request]
jobs:
lintFiles:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check file extensions
run: |
files=$(find "$GITHUB_WORKSPACE/yml" -type f -not -name "*.yml");
if [[ $files ]]; then
echo "::error::Files with unexpected extension found, please ensure you use '.yml' (all lower case) for files in the yml/ folder.";
for i in $files; do echo "::error file=$i,line=1::Unexpected extension"; done
exit 1;
fi
unset files
- name: Check duplicate file names
run: |
files=$(find "$GITHUB_WORKSPACE/yml/OSBinaries" "$GITHUB_WORKSPACE/yml/OtherMSBinaries" -type f -printf '%h %f\n' -iname "*.yml" | sort -t ' ' -k 2,2 -f | uniq -i -f 1 --all-repeated=separate | tr ' ' '/')
if [[ $files ]]; then
echo "::error::Files with duplicate filenames detected, please make sure you don't create duplicate entries.";
for i in $files; do echo "::error file=$i,line=1::Duplicate filename"; done
exit 1;
fi
unset files
- name: Install python dependencies
run: pip install yamllint==1.37.1 pydantic==2.11.9
- name: Lint YAML files
run: yamllint -c .github/.yamllint yml/**/
- name: Validate YAML schemas
run: python3 .github/workflows/validation.py