Skip to content

Commit 5cc65a8

Browse files
chore: add chart audit workflow
1 parent 67a23e7 commit 5cc65a8

File tree

8 files changed

+144
-4
lines changed

8 files changed

+144
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.14
2+
3+
RUN apk add --no-cache \
4+
bash \
5+
ca-certificates \
6+
curl \
7+
wget \
8+
tar \
9+
jq
10+
11+
COPY entrypoint.sh /entrypoint.sh
12+
13+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Install polaris'
2+
description: 'Download a specific polaris version'
3+
4+
inputs:
5+
version:
6+
description: 'version of polaris'
7+
required: true
8+
default: 'latest'
9+
10+
runs:
11+
using: 'docker'
12+
image: './Dockerfile'
13+
args:
14+
- ${{ inputs.version }}
15+
16+
outputs:
17+
version:
18+
description: 'Version of polaris installed'
19+
20+
branding:
21+
icon: 'download-cloud'
22+
color: 'gray-dark'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
if [[ -z "$INPUT_VERSION" ]]; then
3+
echo "Missing polaris version information"
4+
exit 1
5+
fi
6+
polaris version | grep "$INPUT_VERSION" &> /dev/null
7+
if [ $? == 0 ]; then
8+
echo "Polaris $INPUT_VERSION is already installed! Exiting gracefully."
9+
exit 0
10+
else
11+
echo "Installing polaris to path."
12+
fi
13+
TARGET_FILE="polaris.tar.gz"
14+
curl -LJ -o $TARGET_FILE 'https://github.com/FairwindsOps/polaris/releases/download/'"$INPUT_VERSION"'/polaris_linux_amd64.tar.gz'
15+
mkdir polaris
16+
tar -xzf $TARGET_FILE -C polaris
17+
rm $TARGET_FILE
18+
echo "polaris" >> $GITHUB_PATH
19+
echo "::set-output name=version::$INPUT_VERSION"

.github/workflows/chart-audit.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Chart Audit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch: {}
11+
12+
jobs:
13+
polaris:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install Helm
22+
uses: azure/setup-helm@v1
23+
with:
24+
version: v3.4.0
25+
26+
- name: Install Polaris
27+
uses: ./.github/actions/setup-polaris
28+
with:
29+
version: 4.0.7
30+
31+
- name: Polaris Audit
32+
run: |
33+
set -o pipefail
34+
echo '<img src="https://camo.githubusercontent.com/21017bcdf60b658e5719e8d4b8ebf4ba4c1115ea907f2d8190427a82f8979eaf/68747470733a2f2f706f6c617269732e646f63732e6661697277696e64732e636f6d2f696d672f706f6c617269732d6c6f676f2e706e67" width="400" />' > audit-results.out
35+
for chart in $(ls -d helm-charts/*/)
36+
do
37+
echo '<details>' >> audit-results.out
38+
echo "<summary>::RESULT:: Audit results for: ${chart}</summary>" >> audit-results.out
39+
echo '' >> audit-results.out
40+
echo '```bash' >> audit-results.out
41+
polaris audit \
42+
--set-exit-code-on-danger \
43+
--set-exit-code-below-score 85 \
44+
--format pretty \
45+
--helm-chart ${chart} \
46+
--helm-values ${chart}/values.yaml | tee -a audit-results.out
47+
echo '```' >> audit-results.out
48+
echo '</details>' >> audit-results.out
49+
echo '' >> audit-results.out
50+
sed -i'' 's/::RESULT::/:white_check_mark:/' audit-results.out
51+
done
52+
- name: Close details on failure
53+
if: failure() && (github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main')
54+
run: |
55+
echo '```' >> audit-results.out
56+
echo '</details>' >> audit-results.out
57+
sed -i'' 's/::RESULT::/:x:/' audit-results.out
58+
- name: Replace ANSI Colors
59+
if: always() && (github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main')
60+
run: |
61+
sed -i'' -r 's/[[:cntrl:]]\[[0-9]{1,3}(;[0-9]{1})?m//g' audit-results.out
62+
- name: Update PR
63+
if: always() && (github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main')
64+
uses: machine-learning-apps/pr-comment@1.0.0
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
path: audit-results.out
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ jobs:
4646
context: ${{ matrix.app }}
4747
push: ${{ github.event_name != 'pull_request' }}
4848
tags: ${{ steps.meta.outputs.tags }}
49-
labels: ${{ steps.meta.outputs.labels }}
49+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
runs-on: ubuntu-latest
4545
steps:
4646
- uses: actions/checkout@v3
47-
- uses: psf/black@stable
47+
- uses: psf/black@stable

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.0.1
5+
hooks:
6+
#- id: no-commit-to-branch
7+
- id: check-merge-conflict
8+
- id: check-yaml
9+
exclude: ^heplm-charts/.+/templates/
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
- repo: https://github.com/norwoodj/helm-docs
13+
rev: v1.6.0
14+
hooks:
15+
- id: helm-docs
16+
args:
17+
- --chart-search-root=helm-charts
18+
- --template-files=README.md.gotmpl

helm-charts/simplejson-proxy/README.md.gotmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
## Installation
1111
```
12-
helm repo add aws-exporters https://aws-exporters.github.io/charts/
13-
helm install {{ template "chart.name" . }} aws-exporters/{{ template "chart.name" . }}
12+
helm repo add devopsmakers https://devopsmakers.github.io/charts/
13+
helm install {{ template "chart.name" . }} devopsmakers/{{ template "chart.name" . }}
1414
```
1515

1616
{{ template "chart.maintainersSection" . }}

0 commit comments

Comments
 (0)