Created
April 21, 2014 06:03
-
-
Save gitu/11133607 to your computer and use it in GitHub Desktop.
Heroku Manual Slug Upload
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
#!/usr/bin/env bash | |
# bin/compile <build-dir> | |
# fail fast | |
set -e | |
BIN_DIR=$(cd $(dirname $0); pwd) # absolute path | |
BUILD_DIR=$1 | |
curl --silent --location http://heroku-jvm-common.s3.amazonaws.com/jvm-buildpack-common.tar.gz | tar xz | |
. bin/java | |
install_java $BUILD_DIR 1.7 | |
PROFILE_PATH="$BUILD_DIR/.profile.d/java.sh" | |
mkdir -p $(dirname $PROFILE_PATH) | |
echo 'export PATH="/app/.jdk/bin:$PATH"' >> $PROFILE_PATH |
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
#!/usr/bin/env bash | |
# fail fast | |
set -e | |
HEROKU_APP=$1; | |
SLUG_FILE="$2; | |
PROCESS_TYPE=$3; # for example: {"web":"java $JAVA_OPTS -cp target/classes:target/dependency/* HelloWorld"} | |
BASE_URL="https://api.heroku.com/apps/$HEROKU_APP"; | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; | |
echo "deploying to app: $HEROKU_APP"; | |
GIT_SHA="$(git rev-parse HEAD)"; | |
GIT_TAGS="$(git describe --tags)"; | |
NEW_SLUG_POST='{"process_types":'${PROCESS_TYPE}',"commit":"'${GIT_SHA}'","buildpack_provided_description":"manual slug upload"}' | |
echo "we will send this slug info: ${NEW_SLUG_POST}" | |
echo "creating new slug"; | |
NEW_SLUG=$(curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-H 'Accept: application/vnd.heroku+json; version=3' \ | |
-d "${NEW_SLUG_POST}" \ | |
-n ${BASE_URL}/slugs); | |
echo "response was: $NEW_SLUG"; | |
NEW_SLUG_URL=$(echo $NEW_SLUG | grep -Po '(?<="url":")[^"]*'); | |
NEW_SLUG_ID=$(echo $NEW_SLUG | grep -Po '(?<="id":")[^"]*'); | |
echo "new slug $NEW_SLUG_ID has url $NEW_SLUG_URL"; | |
echo "uploading slug $SLUG_FILE"; | |
curl -X PUT -H "Content-Type:" --data-binary @${SLUG_FILE} ${NEW_SLUG_URL}; | |
echo "release slug" | |
curl -X POST \ | |
-H "Accept: application/vnd.heroku+json; version=3" \ | |
-H "Content-Type: application/json" \ | |
-d '{"slug":"'${NEW_SLUG_ID}'"}' \ | |
-n ${BASE_URL}/releases; | |
echo "done you can now visit: http://$HEROKU_APP.herokuapp.com/"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment