Skip to content

Commit 37ef4fb

Browse files
committed
CI yamllint: lint all changed files
Filter out files inside the .yamllint configuration
1 parent c97c7cc commit 37ef4fb

1 file changed

Lines changed: 5 additions & 26 deletions

File tree

.github/workflows/ci_lint.yml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permissions:
66
contents: read
77
jobs:
88
yamllint:
9-
name: Yaml Lint on Changed Controls and Profiles Files
9+
name: Yaml Lint on Changed yaml files
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Install Git
@@ -27,37 +27,16 @@ jobs:
2727
url="repos/$repo/pulls/$pr_number/files"
2828
response=$(gh api "$url" --paginate)
2929
echo "$response" | jq -r '.[].filename' > filenames.txt
30-
cat filenames.txt
31-
32-
if grep -q "controls/" filenames.txt; then
33-
echo "CONTROLS_CHANGES=true" >> $GITHUB_ENV
34-
else
35-
echo "CONTROLS_CHANGES=false" >> $GITHUB_ENV
36-
fi
37-
if grep -q "\.profile" filenames.txt; then
38-
echo "PROFILES_CHANGES=true" >> $GITHUB_ENV
39-
else
40-
echo "PROFILES_CHANGES=false" >> $GITHUB_ENV
41-
fi
4230
env:
4331
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4432

4533
- name: Install yamllint
4634
if: ${{ env.CONTROLS_CHANGES == 'true' || env.PROFILES_CHANGES == 'true' }}
4735
run: pip install yamllint
4836

49-
- name: Run yamllint in Control Files Modified by PR
50-
if: ${{ env.CONTROLS_CHANGES == 'true' }}
51-
run: |
52-
for control_file in $(cat filenames.txt | grep "controls/"); do
53-
echo "Running yamllint on $control_file..."
54-
yamllint "$control_file"
55-
done
56-
57-
- name: Run yamllint in Profile Files Modified by PR
58-
if: ${{ env.PROFILES_CHANGES == 'true' }}
37+
- name: Run yamllint on files modified by the PR
5938
run: |
60-
for profile_file in $(cat filenames.txt | grep "\.profile"); do
61-
echo "Running yamllint on $profile_file..."
62-
yamllint "$profile_file"
39+
for file in $(cat filenames.txt); do
40+
echo "Running yamllint on $file..."
41+
yamllint -c .yamllint "$file"
6342
done

0 commit comments

Comments
 (0)