helm-docs icon indicating copy to clipboard operation
helm-docs copied to clipboard

pre-commit hook in GitHub Action

Open morremeyer opened this issue 4 years ago • 1 comments

Hey and thanks for this tool, it makes my life easier :)

I was wondering how I can use the pre-commit hook with a GitHub action? If I use the official GitHub action for pre-commit and install helm-docs like this, it fails with Please install helm-docs to run the pre-commit hook! https://github.com/norwoodj/helm-docs#installation:

  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-go@v1
      with:
        go-version: '1.16.4'
    - name: Install helm-docs
      run: GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
    - run: helm docs
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
    - uses: pre-commit/[email protected]

Is this due to the pre-commit action being run in its own container, can you maybe help me out here?

morremeyer avatar May 23 '21 23:05 morremeyer

Here's how my github action looks like, hopefully helps!

name: Update docs

on:
  push:
    branches:
      - main

jobs:
  update-readme:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Run helm-docs
        run: |
          GOBIN=$PWD GO111MODULE=on go get github.com/norwoodj/helm-docs/cmd/helm-docs
          ./helm-docs --sort-values-order file
          rm helm-docs

      - name: Commit bump
        uses: EndBug/add-and-commit@v7
        with:
            branch: ${{ github.event.pull_request.base.ref }}
            message: 'Regenerate chart README.md'

macobo avatar Jun 18 '21 08:06 macobo

@macobo this doesn't work any more

maxisam avatar Dec 24 '22 00:12 maxisam

@maxisam check out https://github.com/morremeyer/charts/blob/1badbd9a894fa292c3b4bceadbe8a1f6f7b7e35a/.github/workflows/helm-docs.yml for a working config.

I'll close this since the underlying question I had is resolved.

morremeyer avatar Dec 24 '22 00:12 morremeyer

I ended up having to install helm-docs from source locally, because using the homebrew version appends two extra lines at the bottom (autogenerated using ...) which then caused the CI pipeline to fail git diff --exit-code. It would be nice to have an option to disable this message!

martimors avatar Jun 08 '23 14:06 martimors