CI: Rework docs generation.

This commit is contained in:
Marco Ebert 2024-01-29 23:03:53 +01:00
parent b2e46aa53e
commit 6980e56a63
4 changed files with 13 additions and 24 deletions

View file

@ -234,6 +234,9 @@ jobs:
echo "0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5 /tmp/ah.tar.gz" | shasum --check echo "0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5 /tmp/ah.tar.gz" | shasum --check
sudo tar --extract --file /tmp/ah.tar.gz --directory /usr/local/bin ah sudo tar --extract --file /tmp/ah.tar.gz --directory /usr/local/bin ah
- name: Set up Helm Docs
uses: gabe565/setup-helm-docs-action@d5c35bdc9133cfbea3b671acadf50a29029e87c2 # v1.0.4
- name: Checkout - name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with: with:
@ -252,16 +255,10 @@ jobs:
ct lint --config .ct.yaml ct lint --config .ct.yaml
ah lint --path charts/ingress-nginx ah lint --path charts/ingress-nginx
- name: Run helm-docs - name: Check docs
run: | run: |
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0 helm-docs --chart-search-root charts
./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts git diff --exit-code charts/ingress-nginx/README.md
DIFF=$(git diff ${GITHUB_WORKSPACE}/charts/ingress-nginx/README.md)
if [ ! -z "$DIFF" ]; then
echo "Please use helm-docs in your clone, of your fork, of the project, and commit a updated README.md for the chart. https://github.com/kubernetes/ingress-nginx/blob/main/RELEASE.md#d-edit-the-valuesyaml-and-run-helm-docs"
fi
git diff --exit-code
rm -f ./helm-docs
chart-test: chart-test:
name: Chart / Test name: Chart / Test
@ -281,12 +278,6 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.build.outputs.golangversion }}
check-latest: true
- name: cache - name: cache
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with: with:

1
.gitignore vendored
View file

@ -1,4 +1,3 @@
helm-docs
# OSX # OSX
._* ._*
.DS_Store .DS_Store

View file

@ -226,19 +226,18 @@ Promoting the images basically means that images, that were pushed to staging co
``` ```
### d. Edit the values.yaml and run helm-docs ### d. Edit the values.yaml and run helm-docs
- [Fields to edit in values.yaml](https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml) - [Fields to edit in values.yaml](https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml)
- tag - tag
- digest - digest
- [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a helm-chart automatically. In the CI pipeline workflow of github actions (/.github/workflows/ci.yaml), you can see how helm-docs is used. But the CI pipeline is not designed to make commits back into the project. So we need to run helm-docs manually, and check in the resulting autogenerated README.md at the path /charts/ingress-nginx/README.md - [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a Helm chart automatically. In the CI pipeline workflow of GitHub actions (.github/workflows/ci.yaml), you can see how helm-docs is used. The CI pipeline is not designed to make commits back into the project, so we need to run helm-docs manually and commit the resulting generated README.md. You can obtain a recent version of the helm-docs binary here: https://github.com/norwoodj/helm-docs/releases.
``` ```
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0 helm-docs --chart-search-root charts
./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts git diff charts/ingress-nginx/README.md
git diff --exit-code
rm -f ./helm-docs
``` ```
Watchout for mistakes like leaving the helm-docs executable in your clone workspace or not checking the new README.md manually etc. Take care of not leaving the helm-docs executable in your clone workspace or not committing the new README.md.
### e. Edit the static manifests ### e. Edit the static manifests

View file

@ -170,7 +170,7 @@ func runHelmDocs() error {
if err != nil { if err != nil {
return err return err
} }
err = sh.RunV("helm-docs", "--chart-search-root=${PWD}/charts") err = sh.RunV("helm-docs", "--chart-search-root", "${PWD}/charts")
if err != nil { if err != nil {
return err return err
} }
@ -181,7 +181,7 @@ func installHelmDocs() error {
utils.Info("HELM Install HelmDocs") utils.Info("HELM Install HelmDocs")
g0 := sh.RunCmd("go") g0 := sh.RunCmd("go")
err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0") err := g0("install", "github.com/norwoodj/helm-docs/cmd/helm-docs@latest")
if err != nil { if err != nil {
return err return err
} }