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 80cffe39..6d7dd952 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: @@ -30,7 +31,7 @@ jobs: needs: [build-matrix] strategy: - fail-fast: true + fail-fast: false matrix: chart: ${{ fromJson(needs.build-matrix.outputs.charts) }} @@ -56,6 +57,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."