CI: Rework docs generation.

This commit is contained in:
Marco Ebert 2024-01-29 23:03:53 +01:00
parent f6c88d66a6
commit 543a2bb2c5
4 changed files with 17 additions and 17 deletions

View file

@ -216,16 +216,19 @@ jobs:
- name: Set up Helm Chart Testing - name: Set up Helm Chart Testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1 uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Run helm-docs - name: Set up Helm Docs
uses: gabe565/setup-helm-docs-action@79a4cfe8dc7ae51c1113e3f3a1ae45e601d0c963 # v1.0.3
- name: Generate 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
DIFF=$(git diff ${GITHUB_WORKSPACE}/charts/ingress-nginx/README.md) if ! git diff --exit-code charts/ingress-nginx/README.md
if [ ! -z "$DIFF" ]; then 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" echo "Please use helm-docs in your fork of the project and commit an updated README.md for the chart."
echo "https://github.com/kubernetes/ingress-nginx/blob/main/MANUAL_RELEASE.md#d-edit-the-valuesyaml-and-run-helm-docs"
exit 1
fi fi
git diff --exit-code
rm -f ./helm-docs
- name: Lint chart - name: Lint chart
run: | run: |

1
.gitignore vendored
View file

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

View file

@ -231,14 +231,12 @@ Promoting the images basically means that images, that were pushed to staging co
- 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@v1.11.3")
if err != nil { if err != nil {
return err return err
} }