Skip to content

Instantly share code, notes, and snippets.

@mikepsinn
Forked from ddollar/heroku-deploy.sh
Last active October 12, 2017 22:13
Show Gist options
  • Save mikepsinn/5ab93d5791ad6f9297802eace817d4f9 to your computer and use it in GitHub Desktop.
Save mikepsinn/5ab93d5791ad6f9297802eace817d4f9 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage:
# $ ./heroku-deploy.sh <app name> <heroku api key> <git repo url>
# sudo apt-get install -y curl
# curl https://gist.githubusercontent.com/mikepsinn/5ab93d5791ad6f9297802eace817d4f9/raw/heroku-deploy.sh <app name> <heroku api key> | bash -s
APP="$1"
APIKEY="$2"
REPO="$3"
#echo "-----> Creating application $APP"
#curl -u ":$APIKEY" -d "app[name]=$APP" -X POST https://api.heroku.com/apps -s > /dev/null
echo "-----> Generating bootstrap script"
BOOTSTRAPPER=$(cat<<SCRIPT
mkdir -p ~/.ssh || true
cat <<EOF > ~/.ssh/config
Host heroku.com
UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no
EOF
ssh-keygen -t dsa -N "" -f /app/.ssh/id_dsa -C "heroku-deploy.sh"
curl -u ":$APIKEY" -d @/app/.ssh/id_dsa.pub -X POST https://api.heroku.com/user/keys
#git clone $REPO repo
#cd repo
git remote add heroku "[email protected]:$APP.git"
git push heroku master
#curl -u ":$APIKEY" -X DELETE https://api.heroku.com/user/keys/heroku-deploy%2Esh
SCRIPT
)
echo "-----> Running bootstrap script on Heroku"
#curl -u ":$APIKEY" -F "command=$BOOTSTRAPPER" -X POST https://api.heroku.com/apps/$APP/ps -s > /dev/null
#echo " Bootstrap script is now deploying code from $REPO"
#sleep 50
echo
echo "-----> Application should be running momentarily at:"
echo " http://$APP.herokuapp.com"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment