-
Notifications
You must be signed in to change notification settings - Fork 34
71 lines (58 loc) · 1.7 KB
/
lintcharts.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Lint Helm charts
# Only runs when charts have changed
# Lint Helm charts
on:
pull_request:
branches:
- master
paths:
- charts/**
jobs:
# Get the paths for the Helm charts to lint
get_paths:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get the paths for Helm charts to lint
id: set-matrix
run: |
# Get paths (in string form)
stringPaths=$(find -maxdepth 2 -path './charts/*')
# Check paths (length greater than 0)
stringPathsLength=$(echo ${#stringPaths})
if (( stringPathsLength == 0 ));
then
echo "No paths to check"
exit 1
fi
# Serialize paths into JSON array
paths=$(jq -ncR '[inputs]' <<< "$stringPaths")
# Output serialized paths
echo "matrix=$paths" >> $GITHUB_OUTPUT
echo $paths
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
# Lint Helm charts based on paths provided by previous job
lint:
name: Test changed-files
needs: get_paths
runs-on: ubuntu-latest
strategy:
matrix:
version: ${{ fromJson(needs.get_paths.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get modified files in the ${{ matrix.version }} folder
id: modified-files
uses: tj-actions/changed-files@v35
with:
files: ${{ matrix.version }}
- name: Lint Helm charts in the ${{ matrix.version }} folder
uses: stackrox/kube-linter-action@v1
if: steps.modified-files.outputs.any_modified == 'true'
with:
directory: ${{ matrix.version }}