Created
November 13, 2013 20:43
-
-
Save enyachoke/7456079 to your computer and use it in GitHub Desktop.
This is a git pre-recieve hook that compiles a slug using heroku buildpacks and optionally uploads it to s3 and generate a pre-signed url for downloading it. This script assumes you have s3cmd installed and configured.
This file contains hidden or 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/bash | |
while read oldrev newrev refname | |
do | |
# Only build the master branch. | |
if [[ $refname = "refs/heads/master" ]] ; then | |
echo "building------> $newrev ... " | |
#We get the archive and pass it to the slug builder | |
slug_id=newapp | |
git archive $newrev | docker run -i -name $newrev -a stdin -a stdout -a stderr flynn/slugbuilder - > $newrev.tgz | |
# s3cmd put $newrev.tgz s3://pyxiscloud/$newrev.tgz | |
#s3cmd signurl s3://pyxiscloud/$newrev.tgz | |
#s3cmd signurl s3://pyxiscloud/$newrev.tgz "1415837645" | |
docker rm $newrev | |
#mv $newrev.tgz ../../$newrev.tgz | |
# $? is a shell variable which stores the return code from what we just ran | |
rc=$? | |
if [[ $rc != 0 ]] ; then | |
# A non-zero return code means an error occurred, so tell the user and exit | |
echo "for some reason we where unable to build $newrev - Please try again" | |
exit $rc | |
fi | |
fi | |
done | |
# Bingo | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment