Skip to content

Instantly share code, notes, and snippets.

@vishnu-narayanan
Last active August 25, 2020 15:18
Show Gist options
  • Select an option

  • Save vishnu-narayanan/08524df1cdfa9a0753785d60ec532936 to your computer and use it in GitHub Desktop.

Select an option

Save vishnu-narayanan/08524df1cdfa9a0753785d60ec532936 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
## Pre-commit hook validation script for the developers.
## Variables
HOOK_FILE_URL="https://raw.githubusercontent.com/Flux7Labs/central-repo-git-hooks/master/.pre-commit-config.yaml"
ARGS="--all-files"
PKGS="pre-commit cfn-lint flake8 checkov"
BASEDIR="/tmp/hooks"
HOOK_FILE="${BASEDIR}/hookfile"
mkdir -p ${BASEDIR}
curl ${HOOK_FILE_URL} > ${HOOK_FILE}
if [[ -f ${HOOK_FILE} ]]; then
pip3 install $PKGS
pre-commit install
pre-commit clean
pre-commit run -c ${HOOK_FILE} ${ARGS}
pre-commit clean
rm -f ${HOOK_FILE}
else
echo "Unable to download ${HOOK_FILE_URL}. Exiting.."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment