Skip to content

Instantly share code, notes, and snippets.

@kljensen
Created January 5, 2021 23:17
Show Gist options
  • Save kljensen/5cafb89d29ff57c68aec2dff67392883 to your computer and use it in GitHub Desktop.
Save kljensen/5cafb89d29ff57c68aec2dff67392883 to your computer and use it in GitHub Desktop.
Git pre-commit hook to check/lint YAML format before committing
#!/bin/sh
# This file, or contents like below, should be in
# .git/hooks/pre-commit. If you have a YAML file
# with invalid formatting, the commit will be aborted.
# Check formatting of all yaml files.
# Uses yq v4. For v3 use 'r' instead of 'e'
fd -t f --regex '.*\.yaml' -x yq e {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment