Skip to content

Instantly share code, notes, and snippets.

@brenolf
Last active October 31, 2016 23:28
Show Gist options
  • Select an option

  • Save brenolf/d7ccd8285a8e5b1cc70da456cb4c4874 to your computer and use it in GitHub Desktop.

Select an option

Save brenolf/d7ccd8285a8e5b1cc70da456cb4c4874 to your computer and use it in GitHub Desktop.

Revisions

  1. brenolf revised this gist Aug 29, 2016. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -2,20 +2,20 @@

    PROJECT=name;

    if [[ $1 == "staging" || $1 == "production" ]]; then
    TARGET=`echo $1 | tr '[:lower:]' '[:upper:]'`;
    if [[ "$1" == "staging" || "$1" == "production" ]]; then
    TARGET=`echo "$1" | tr '[:lower:]' '[:upper:]'`;

    read -p "Do you really wish to deploy to $TARGET? [yn] " yn
    read -p "Do you really wish to deploy to $TARGET? [yn] " yn;

    if [[ $yn != "y" ]]; then
    if [[ "$yn" != "y" ]]; then
    exit 0;
    fi
    else
    echo "You must supply a parameter: 'staging' or 'production'";
    exit 1;
    fi

    if [[ $1 == "staging" ]]; then
    if [[ "$1" == "staging" ]]; then
    BRANCH=staging;
    else
    BRANCH=production;
    @@ -51,6 +51,6 @@ git checkout -f @{-2};
    git branch -D $TMP;
    git stash pop;

    bower install;
    bower install --force;

    exit 0;
  2. brenolf created this gist Aug 25, 2016.
    56 changes: 56 additions & 0 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    #!/bin/bash

    PROJECT=name;

    if [[ $1 == "staging" || $1 == "production" ]]; then
    TARGET=`echo $1 | tr '[:lower:]' '[:upper:]'`;

    read -p "Do you really wish to deploy to $TARGET? [yn] " yn

    if [[ $yn != "y" ]]; then
    exit 0;
    fi
    else
    echo "You must supply a parameter: 'staging' or 'production'";
    exit 1;
    fi

    if [[ $1 == "staging" ]]; then
    BRANCH=staging;
    else
    BRANCH=production;
    fi

    TMP=tmp-deploy-branch-`date +%s`;

    rm -rf dist bower_components;

    bower install;

    NODE_ENV=$BRANCH gulp;

    git stash save -u;

    git checkout master;
    git pull;

    git checkout -b $TMP;

    sed -i -e 's/dist\///;s/bower_components//' .gitignore;

    heroku git:remote -a $PROJECT-$BRANCH;
    git add -A;
    git commit -m "`date`";

    heroku maintenance:on --app $PROJECT-$BRANCH;
    git push -f git@heroku.com:$PROJECT-$BRANCH.git $TMP:master;
    heroku run --app $PROJECT-$BRANCH -- npm run migrate;
    heroku maintenance:off --app $PROJECT-$BRANCH;

    git checkout -f @{-2};
    git branch -D $TMP;
    git stash pop;

    bower install;

    exit 0;