Created
September 30, 2021 00:10
-
-
Save scottharwell/726288ffc633bc2e863c59dbd971e831 to your computer and use it in GitHub Desktop.
Hook for Ansible projects that require a `yamllint` and `ansible-lint` check before any commit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Run yamllint first to ensure that code passes checks | |
yamllint . | |
YAML_LINT=$? | |
# Go ahead and stop if yamllint fails since ansible-lint takes a while | |
if [ $YAML_LINT == 1 ]; then | |
exit 1 | |
fi | |
# Run ansible-lint to ensure ansible checks | |
ansible-lint | |
ANSIBLE_LINT=$? | |
EXIT_CODE=$(($YAML_LINT + $ANSIBLE_LINT)) | |
exit $EXIT_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment