-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 1.5 KB
/
workflow-yaml-check.yml
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
53
54
55
56
---
name: Check Yaml conformance to AI Lab standards
on:
workflow_call:
inputs:
config-file-path:
required: false
type: string
push:
jobs:
yaml-lint-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
id: files
uses: lots0logs/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install yamllint
run: pip install yamllint
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ai-cfia/github-workflows
path: github-workflows
ref: main
sparse-checkout: |
.yamllint.yml
sparse-checkout-cone-mode: false
- name: Determine yaml lint config file
id: lintconfig
run: |
if [ -z "${{ inputs.config-file-path }}" ]; then
echo "::set-output name=lint_config_path::github-workflows/.yamllint.yml"
else
echo "::set-output name=lint_config_path::${{ inputs.config-file-path }}"
fi
- name: Lint YAML files
run: |
files=$(echo '${{ steps.files.outputs.all }}' | jq -r '.[]')
for file in $files; do
if [[ -f "$file" && ( $file == *.yml || $file == *.yaml ) ]]; then
yamllint -c "${{ github.workspace }}/${{ steps.lintconfig.outputs.lint_config_path }}" "$file"
fi
done
shell: bash