Last active
December 20, 2015 21:58
-
-
Save JorgenEvens/6201280 to your computer and use it in GitHub Desktop.
Test the build using a custom heroku buildpack on your own machine.
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
#!/bin/sh | |
if [ -z $1 ]; then | |
echo "Usage: $0 project-location" | |
exit 1 | |
fi | |
if [ ! -d $1 ]; then | |
echo "Could not find your project" | |
exit 2 | |
fi | |
if [ -z $BUILDPACK_URL ]; then | |
echo "No buildpack specified, can only test custom buildpacks" | |
exit 3; | |
fi | |
# Setup directories | |
PROJECT="$1" | |
BASE=`mktemp` | |
PROJECT_TMP="$BASE/project" | |
BUILDPACK_TMP="$BASE/buildpack" | |
if [ -z "$CACHE_TMP" ]; then | |
CACHE_TMP="$BASE/cache" | |
fi | |
# Remove the temporary file, as we want a directory | |
rm -R "$BASE" | |
# Get buildpack | |
mkdir -p "$BUILDPACK_TMP" | |
git clone "${BUILDPACK_URL}" "$BUILDPACK_TMP" | |
# Create a copy of the project | |
cp -R "$PROJECT" "$PROJECT_TMP" | |
# Remove repository information | |
rm -Rf "$PROJECT_TMP/.git" | |
# Execute detection | |
APP=$(${BUILDPACK_TMP}/bin/detect "$PROJECT_TMP") | |
if [ $? -gt 0 ]; then | |
echo "No app detected" | |
exit 4 | |
fi | |
echo "Detected $APP application" | |
# Execute buildpack | |
${BUILDPACK_TMP}/bin/compile "$PROJECT_TMP" "$CACHE_TMP" | |
# Create an archive of the result | |
tar -caf "build-$(date +%d-%m-%y_%H-%M).tar.gz" -C "$BASE" "$(basename $PROJECT_TMP)" | |
rm -Rf "$BASE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment