Skip to content

Instantly share code, notes, and snippets.

@ahobson
Created May 15, 2019 14:33
Show Gist options
  • Save ahobson/e6d698dff9a8361d7cc350bf44649b66 to your computer and use it in GitHub Desktop.
Save ahobson/e6d698dff9a8361d7cc350bf44649b66 to your computer and use it in GitHub Desktop.
pre-commit
#!/bin/bash
set -euo pipefail
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
rootdir="$(cd $scriptdir/../.. > /dev/null 2>&1 && pwd)"
circleconfig="${rootdir}/.circleci/config.yml"
image=$(ruby -ryaml -e 'puts YAML.load_file(ARGV.last).dig("jobs","build","docker", 0, "image")' $circleconfig)
exec docker run \
-i \
--rm=true \
-v ${rootdir}:/app \
-v ${rootdir}/.pre-commit-cache:/home/circleci/.cache \
-w /app \
${image} \
/app/.git/hooks/pre-commit.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment