-
Notifications
You must be signed in to change notification settings - Fork 1
226 lines (185 loc) Β· 6.62 KB
/
pullrequest.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: "Pullrequest"
on:
pull_request:
jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ibiqlik/action-yamllint@v3
id: lint
continue-on-error: true
with:
file_or_dir: .
format: standard
config_file: .yamllint.yml
- name: single-line
id: lint-output
if: steps.lint.outcome != 'success'
run: |
echo "logfile=$(sed ':a;N;$!ba;s/\n/{newline}/g' < ${{ steps.lint.outputs.logfile }} )" >> $GITHUB_OUTPUT
- name: Augment PR with yamllint infos
uses: actions/[email protected]
if: steps.lint.outcome != 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### yamllint: π\`${{ steps.kubeval.outcome }}\`
<details><summary>Show results</summary>
\`\`\`
${{ steps.lint-output.outputs.logfile }}
\`\`\`
</details>
__Author:__ @${{ github.actor }},
__Action:__ \`${{ github.event_name }}\``;
new_output = output.replace(/{newline}/g, "\n");
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: new_output
})
- name: Fail pipeline if previously failed
if: steps.lint.outcome != 'success'
run: exit 1
kubeval_manifests:
name: "run kubeval on plain K8s manifests"
runs-on: ubuntu-latest
needs: lint
steps:
- uses: cedi-dev/gh-action-install-kubeval@main
- name: Checkout
uses: actions/checkout@v4
- name: Kubeval
id: kubeval
continue-on-error: true
run: |
set -e
touch kubeval.txt
for manifest in ./manifests/*/*.yaml
do
echo "$manifests"
kubeval --ignore-missing-schemas --strict --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/ $manifest | tee -a kubeval.txt
done
echo "kubeval=$(sed ':a;N;$!ba;s/\n/{newline}/g' < kubeval.txt)" >> $GITHUB_OUTPUT
- name: Augment PR with kubeval infos
uses: actions/[email protected]
if: steps.kubeval.outcome != 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Kubeval manifests: π\`${{ steps.kubeval.outcome }}\`
<details><summary>Show results</summary>
\`\`\`
${{ steps.kubeval.outputs.kubeval }}
\`\`\`
</details>
__Author:__ @${{ github.actor }},
__Action:__ \`${{ github.event_name }}\``;
new_output = output.replace(/{newline}/g, "\n");
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: new_output
})
- name: Fail pipeline if previously failed
if: steps.kubeval.outcome != 'success'
run: exit 1
kubeval_charts:
name: "run kubeval on charts"
runs-on: ubuntu-latest
needs: lint
steps:
- uses: cedi-dev/gh-action-install-kubeval@main
- name: Checkout
uses: actions/checkout@v4
- name: Charts
id: kubeval
continue-on-error: true
run: |
set -e
touch kubeval.txt
for chart in ./charts/*/
do
echo "$chart"
for app in $stage*/
do
echo "$chart"
pushd $chart
pwd
helm dependency update
helm template . --values ./values.yaml | kubeval --ignore-missing-schemas --strict | tee -a kubeval.txt
popd
done
done
echo "kubeval=$(sed ':a;N;$!ba;s/\n/{newline}/g' < kubeval.txt)" >> $GITHUB_OUTPUT
- name: Augment PR with kubeval infos
uses: actions/[email protected]
if: steps.kubeval.outcome != 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Kubeval charts: π\`${{ steps.kubeval.outcome }}\`
<details><summary>Show results</summary>
\`\`\`
${{ steps.kubeval.outputs.kubeval }}
\`\`\`
</details>
__Author:__ @${{ github.actor }},
__Action:__ \`${{ github.event_name }}\``;
new_output = output.replace(/{newline}/g, "\n");
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: new_output
})
- name: Fail pipeline if previously failed
if: steps.kubeval.outcome != 'success'
run: exit 1
kubeval_kustomize:
name: "run kubeval on Kustomize overlays"
runs-on: ubuntu-latest
needs: lint
steps:
- uses: cedi-dev/gh-action-install-kubeval@main
- name: Checkout
uses: actions/checkout@v4
- name: Kustomize
id: kubeval
run: |
set -e
touch kubeval.txt
for kust in ./kustomize/overlays/*/*
do
echo "$kust"
kustomize build --enable-alpha-plugins --enable-helm $kust | kubeval --ignore-missing-schemas --strict | tee -a kubeval.txt
done
echo "kubeval=$(sed ':a;N;$!ba;s/\n/{newline}/g' < kubeval.txt)" >> $GITHUB_OUTPUT
- name: Augment PR with kubeval infos
uses: actions/[email protected]
if: steps.kubeval.outcome != 'success'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Kubeval kustomize: π\`${{ steps.kubeval.outcome }}\`
<details><summary>Show results</summary>
\`\`\`
${{ steps.kubeval.outputs.kubeval }}
\`\`\`
</details>
__Author:__ @${{ github.actor }},
__Action:__ \`${{ github.event_name }}\``;
new_output = output.replace(/{newline}/g, "\n");
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: new_output
})
- name: Fail pipeline if previously failed
if: steps.kubeval.outcome != 'success'
run: exit 1