-
Notifications
You must be signed in to change notification settings - Fork 7
42 lines (36 loc) · 1.21 KB
/
lint.yaml
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
name: Lint
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
jobs:
lint-changed-yaml:
name: Lint changed yaml files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get list of changed yaml files
id: changed-files
uses: tj-actions/changed-files@v45
with:
# Required to correctly handle filenames containing non-alphanumeric
# characters
quotepath: "false"
files: |
**/*.yaml
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
# Print each changed file on a newline
echo "$ALL_CHANGED_FILES" | tr ' ' '\n'
- name: Run yamllint
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
# changed-files adds backslashes to non-ascii file names. We need to
# remove those backslashes before running yamllint
sanitized_file=$(echo "$file" | sed -e 's/\\//g')
# Run yamllint on the sanitized file path
yamllint "$sanitized_file"
done