From 4ee83bb549ca00e9ce5c779558071123b7607a71 Mon Sep 17 00:00:00 2001 From: Marco Franssen Date: Wed, 30 Nov 2022 13:02:29 +0100 Subject: [PATCH] Check for helm-docs are updated Signed-off-by: Marco Franssen --- .github/helm-docs.sh | 39 ++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 5 +++++ .gitignore | 2 ++ CONTRIBUTING.md | 6 ++++++ 4 files changed, 52 insertions(+) create mode 100755 .github/helm-docs.sh diff --git a/.github/helm-docs.sh b/.github/helm-docs.sh new file mode 100755 index 00000000..a8b2bbe4 --- /dev/null +++ b/.github/helm-docs.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPTPATH=$(dirname "$0") +HELM_DOCS_VERSION="1.11.0" + +function install_helm_docs { + case "$(uname -s)" in + Linux*) + machine=Linux + shasum=sha256sum + ;; + Darwin*) + machine=Darwin + shasum=shasum + ;; + esac + + curl -LO https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_${machine}_x86_64.tar.gz + curl -L --output /tmp/checksums_helm-docs.txt https://github.com/norwoodj/helm-docs/releases/download/v${HELM_DOCS_VERSION}/checksums.txt + grep helm-docs_${HELM_DOCS_VERSION}_${machine}_x86_64.tar.gz /tmp/checksums_helm-docs.txt | $shasum -c - + mkdir -p "$SCRIPTPATH/bin" + tar -xf helm-docs_"${HELM_DOCS_VERSION}"_${machine}_x86_64.tar.gz helm-docs + mv helm-docs "$SCRIPTPATH/bin/" + rm helm-docs_"${HELM_DOCS_VERSION}"_${machine}_x86_64.tar.gz +} + +if [ ! -f "$SCRIPTPATH/bin/helm-docs" ] ; then + install_helm_docs +elif [[ ! "$("$SCRIPTPATH/bin/helm-docs" --version)" =~ .*"$HELM_DOCS_VERSION".* ]] ; then + install_helm_docs +else + echo "Using '$("$SCRIPTPATH/bin/helm-docs" --version)'" +fi + +# validate docs +"$SCRIPTPATH/bin/helm-docs" -t "$SCRIPTPATH/README.md.tmpl" -g $1 +git diff --exit-code diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c006cfa..03336102 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: pull_request: paths: - ".github/workflows/test.yml" + - ".github/helm-docs.sh" - "charts/**" jobs: @@ -46,6 +47,10 @@ jobs: git diff --exit-code working-directory: ${{ matrix.chart }} + - name: Check docs updated + run: .github/helm-docs.sh . + working-directory: ${{ matrix.chart }} + test: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index c81f8645..e9b8ff01 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ charts/*/Chart.lock # Vim swap files *.swp + +.github/bin diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42fb98d1..f89531a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,5 +57,11 @@ Any changes to Chart.yaml or values.yaml require an update of the README.md. Thi helm-docs -g charts/«chart-name» ``` +or + +```shell +.github/helm-docs.sh charts/«chart-name» +``` + [crane]: https://github.com/google/go-containerregistry/blob/main/cmd/crane/doc/crane.md "Crane is a tool for managing container images" [helm-docs]: https://github.com/norwoodj/helm-docs "The helm-docs tool auto-generates documentation from helm charts into markdown files."