Adding this to our pre-commit GHA helps keep our s...
# github-actions
j
Adding this to our pre-commit GHA helps keep our stacks formatted consistently.
.pre-commit-config.yaml
Copy code
repos:
  - repo: https://github.com/google/yamlfmt
    rev: v0.9.0
    hooks:
      - id: yamlfmt
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.77.1
    hooks:
      - id: terraform_fmt
      - id: terraform_docs
        args: ["--args=--lockfile=false"]
.yamlfmt
Copy code
formatter:
  type: basic
  retain_line_breaks: true
  indentless_arrays: false
  drop_merge_tag: true
GHA in thread
fiesta parrot 1
Copy code
- uses: actions/setup-go@v4
        with:
          go-version: "1.18.0"

      - run: go install github.com/google/yamlfmt/cmd/yamlfmt@latest

      - uses: actions/setup-python@v3
        with:
          python-version: 2.x
          token: ${{ secrets.GHA_SERVICE_ACCOUNT_TOKEN }}

      # pre-commit checks: fmt + terraform-docs
      # We skip tf_validate as it requires an init
      # of all root modules, which is to be avoided.
      - uses: cloudposse/github-action-pre-commit@v3.0.0
        env:
          SKIP: tf_validate
        with:
          token: ${{ secrets.GHA_SERVICE_ACCOUNT_TOKEN }}
          git_user_name: ${{ secrets.GHA_SERVICE_ACCOUNT_USER_NAME }}
          git_user_email: ${{ secrets.GHA_SERVICE_ACCOUNT_USER_EMAIL }}
          git_commit_message: "chore(pre-commit): linting"
          extra_args: --all-files
so basically the same as the CP GHA example, but the first 2 steps are new (
setup-go
and
go install ....
)