Skip to content

Instantly share code, notes, and snippets.

@caseycoding
Created May 10, 2018 03:06
Show Gist options
  • Save caseycoding/89787c49f4bd37cc9477b3c448324245 to your computer and use it in GitHub Desktop.
Save caseycoding/89787c49f4bd37cc9477b3c448324245 to your computer and use it in GitHub Desktop.
Circle CI Pre-commit hook
#!/bin/sh
# If validation fails, tell circleci to stop and provide error message. Otherwise, continue.
if ! [ -x "$(command -v circleci)" ]; then
echo 'Error: circle is not installed. Circle config validation will not occur.' >&2
exit 0
else
# The following line is needed by the CircleCI Local Build Tool (due to Docker interactivity)
exec < /dev/tty
# If validation fails, tell Git to stop and provide error message. Otherwise, continue.
if ! eMSG=$(circleci config validate -c .circleci/config.yml); then
echo "CircleCI Configuration Failed Validation."
echo $eMSG
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment