Skip to content

Instantly share code, notes, and snippets.

@christianrojas
Forked from jonah-williams/circle.yml
Created May 12, 2016 11:26
Show Gist options
  • Select an option

  • Save christianrojas/e9c68c4b7e5b88b9bedaa3ee0b56a080 to your computer and use it in GitHub Desktop.

Select an option

Save christianrojas/e9c68c4b7e5b88b9bedaa3ee0b56a080 to your computer and use it in GitHub Desktop.

Revisions

  1. Jonah revised this gist Aug 28, 2013. 5 changed files with 5 additions and 0 deletions.
    1 change: 1 addition & 0 deletions heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,7 @@ git push heroku $CIRCLE_SHA1:refs/heads/master
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku scale worker=$PREV_WORKERS --app $APP_NAME
    heroku restart --app $APP_NAME
    fi

    heroku run rake cache:flush --app $APP_NAME
    1 change: 1 addition & 0 deletions naive_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,5 @@ APP_NAME=$1
    heroku maintenance:on --app $APP_NAME
    git push heroku $CIRCLE_SHA1:refs/heads/master
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku restart --app $APP_NAME
    heroku maintenance:off --app $APP_NAME
    1 change: 1 addition & 0 deletions persistent_pipeline_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -49,6 +49,7 @@ fi
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate --app $APP_NAME
    heroku run rake db:seed --app $APP_NAME
    heroku restart --app $APP_NAME
    fi
    )
    MIGRATION_EXIT=$? # store the exit code
    1 change: 1 addition & 0 deletions pipeline_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,7 @@ heroku pipeline:promote --app $PIPELINE_APP_NAME
    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku restart --app $APP_NAME
    heroku scale worker=$PREV_WORKERS --app $APP_NAME
    fi

    1 change: 1 addition & 0 deletions precompile_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,7 @@ git push heroku HEAD:refs/heads/master -f
    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku restart --app $APP_NAME
    heroku scale worker=$PREV_WORKERS --app $APP_NAME
    fi

  2. Jonah revised this gist Aug 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion persistent_pipeline_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -6,14 +6,14 @@ [email protected]:$PIPELINE_APP_NAME.git
    WORKERS_COUNT=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # configure pipeline deploy https://devcenter.heroku.com/articles/labs-pipelines
    heroku plugins:install git://github.com/heroku/heroku-pipeline.git
    if test $(heroku apps | grep $PIPELINE_APP_NAME -c) -gt 0; then
    echo "Using existing pipeline $PIPELINE_APP_NAME"
    git remote add pipeline $HEROKU_PIPELINE_REMOTE
    DIFF_REMOTE=pipeline
    else
    heroku apps:create $PIPELINE_APP_NAME --remote pipeline
    heroku labs:enable pipelines --app $PIPELINE_APP_NAME
    heroku plugins:install git://github.com/heroku/heroku-pipeline.git
    heroku pipeline:add $APP_NAME --app $PIPELINE_APP_NAME
    heroku pipeline --app $PIPELINE_APP_NAME

  3. Jonah revised this gist Aug 24, 2013. 1 changed file with 79 additions and 0 deletions.
    79 changes: 79 additions & 0 deletions persistent_pipeline_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    #!/bin/sh -e
    APP_NAME=$1
    PIPELINE_APP_NAME=$APP_NAME-slug
    [email protected]:$APP_NAME.git
    [email protected]:$PIPELINE_APP_NAME.git
    WORKERS_COUNT=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # configure pipeline deploy https://devcenter.heroku.com/articles/labs-pipelines
    if test $(heroku apps | grep $PIPELINE_APP_NAME -c) -gt 0; then
    echo "Using existing pipeline $PIPELINE_APP_NAME"
    git remote add pipeline $HEROKU_PIPELINE_REMOTE
    DIFF_REMOTE=pipeline
    else
    heroku apps:create $PIPELINE_APP_NAME --remote pipeline
    heroku labs:enable pipelines --app $PIPELINE_APP_NAME
    heroku plugins:install git://github.com/heroku/heroku-pipeline.git
    heroku pipeline:add $APP_NAME --app $PIPELINE_APP_NAME
    heroku pipeline --app $PIPELINE_APP_NAME

    git remote add heroku $HEROKU_APP_REMOTE
    DIFF_REMOTE=heroku
    fi

    # configure app and check for db changes
    git fetch $DIFF_REMOTE
    MIGRATION_CHANGES=$(git diff $CIRCLE_SHA1 $DIFF_REMOTE/master --name-only -- db | wc -l)
    echo "$MIGRATION_CHANGES db changes since last deploy."

    # use pipeline to prepare a slug to deploy
    git push pipeline $CIRCLE_SHA1:refs/heads/master

    DEPLOY_START=`date +%s`

    # migrations require downtime so enter maintenance mode
    if test $MIGRATION_CHANGES -gt 0; then
    heroku maintenance:on --app $APP_NAME

    # Make sure workers are not running during a migration
    heroku scale worker=0 --app $APP_NAME
    fi

    # Run our migrations in a subprocess so that failed db migrations
    # don't immediately abort our deploy script.
    (
    # promote the compiled slug
    heroku pipeline:promote --app $PIPELINE_APP_NAME

    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate --app $APP_NAME
    heroku run rake db:seed --app $APP_NAME
    fi
    )
    MIGRATION_EXIT=$? # store the exit code

    # Always scale our workers back up, regardless of whether the migration failed
    if test $MIGRATION_CHANGES -gt 0; then
    heroku scale worker=$WORKERS_COUNT --app $APP_NAME
    fi

    # If the migration failed, now we can exit with that exit code
    if test $MIGRATION_EXIT -ne 0; then
    exit $MIGRATION_EXIT
    fi

    heroku run rake cache:flush --app $APP_NAME
    heroku maintenance:off --app $APP_NAME

    DEPLOY_END=`date +%s`
    ELAPSED=$(( $DEPLOY_END - $DEPLOY_START ))

    echo "Deploy completed!"
    if test $MIGRATION_CHANGES -gt 0; then
    echo " $ELAPSED seconds in maintenance mode."
    else
    echo " $ELAPSED seconds, without maintenance mode."
    fi

    exit 0
  4. Jonah revised this gist Aug 8, 2013. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions naive_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/bin/sh -e
    APP_NAME=$1

    heroku maintenance:on --app $APP_NAME
    git push heroku $CIRCLE_SHA1:refs/heads/master
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku maintenance:off --app $APP_NAME
  5. Jonah revised this gist Jul 19, 2013. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions precompile_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/bin/sh -e
    APP_NAME=$1

    git remote add heroku [email protected]:$APP_NAME.git
    git fetch heroku
    MIGRATION_CHANGES=$(git diff HEAD heroku/master --name-only -- db | wc -l)
    echo "$MIGRATION_CHANGES db changes since last deploy."

    rake assets:precompile
    git config user.name "CircleCi"
    git config user.email "[email protected]"
    git add public/assets
    git commit -m "Precompile assets"

    PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # migrations require downtime so enter maintenance mode
    if test $MIGRATION_CHANGES -gt 0; then
    heroku maintenance:on --app $APP_NAME

    # Make sure workers are not running during a migration
    heroku scale worker=0 --app $APP_NAME
    fi

    # deploy code changes (and implicitly restart the app and any running workers)
    git push heroku HEAD:refs/heads/master -f

    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku scale worker=$PREV_WORKERS --app $APP_NAME
    fi

    heroku run rake cache:flush --app $APP_NAME
    heroku maintenance:off --app $APP_NAME
  6. Jonah revised this gist Jul 19, 2013. 2 changed files with 85 additions and 56 deletions.
    63 changes: 7 additions & 56 deletions heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,12 @@
    #!/bin/sh -e
    APP_NAME=$1
    PIPELINE_APP_NAME=$APP_NAME-slug
    [email protected]:$APP_NAME.git
    [email protected]:$PIPELINE_APP_NAME.git
    WORKERS_COUNT=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # configure pipeline deploy https://devcenter.heroku.com/articles/labs-pipelines
    if test $(heroku apps | grep $PIPELINE_APP_NAME -c) -gt 0; then
    echo "Using existing pipeline $PIPELINE_APP_NAME"
    git remote add pipeline $HEROKU_PIPELINE_REMOTE
    else
    heroku apps:create $PIPELINE_APP_NAME --remote pipeline
    heroku labs:enable pipelines --app $PIPELINE_APP_NAME
    fi
    heroku plugins:install git://github.com/heroku/heroku-pipeline.git
    heroku pipeline:add $APP_NAME --app $PIPELINE_APP_NAME
    heroku pipeline --app $PIPELINE_APP_NAME

    # configure app and check for db changes
    git remote add heroku $HEROKU_APP_REMOTE
    git remote add heroku [email protected]:$APP_NAME.git
    git fetch heroku
    MIGRATION_CHANGES=$(git diff $CIRCLE_SHA1 heroku/master --name-only -- db | wc -l)
    echo "$MIGRATION_CHANGES db changes since last deploy."
    MIGRATION_CHANGES=$(git diff HEAD heroku/master --name-only -- db | wc -l)
    echo "$MIGRATION_CHANGES db changes."

    # use pipeline to prepare a slug to deploy
    git push pipeline $CIRCLE_SHA1:refs/heads/master

    DEPLOY_START=`date +%s`
    PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # migrations require downtime so enter maintenance mode
    if test $MIGRATION_CHANGES -gt 0; then
    @@ -36,8 +16,8 @@ if test $MIGRATION_CHANGES -gt 0; then
    heroku scale worker=0 --app $APP_NAME
    fi

    # promote the compiled slug
    heroku pipeline:promote --app $PIPELINE_APP_NAME
    # deploy code changes (and implicitly restart the app and any running workers)
    git push heroku $CIRCLE_SHA1:refs/heads/master

    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    @@ -46,33 +26,4 @@ if test $MIGRATION_CHANGES -gt 0; then
    fi

    heroku run rake cache:flush --app $APP_NAME
    heroku maintenance:off --app $APP_NAME

    DEPLOY_END=`date +%s`
    ELAPSED=$(( $DEPLOY_END - $DEPLOY_START ))

    # HACK!
    # Pipelines do not update the git repository on downstream apps.
    #
    # In order to be able to diff for db changes against the app overwrite the pipeline
    # deploy with a git push of the same commit.
    #
    # Since this we already ran any required migrations this can always be a
    # zero-downtime deploy we don't need to enable maintenance mode and are no longer
    # sensetive to long asset precompilation times or other delays.
    #
    # We could remove this if we want to maintain a persistent pipeline app and always
    # diff against that app to determine if db changes exist. Alternately we might
    # be able to parse `heroku pipeline:diff` output for commit hashes and check for
    # db changes in each commit.
    git push heroku $CIRCLE_SHA1:refs/heads/master -f

    # remove the pipeline app
    heroku apps:destroy --app $PIPELINE_APP_NAME --confirm $PIPELINE_APP_NAME

    echo "Deploy completed!"
    if test $MIGRATION_CHANGES -gt 0; then
    echo " $ELAPSED seconds in maintenance mode."
    else
    echo " $ELAPSED seconds, without maintenance mode."
    fi
    heroku maintenance:off --app $APP_NAME
    78 changes: 78 additions & 0 deletions pipeline_heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    #!/bin/sh -e
    APP_NAME=$1
    PIPELINE_APP_NAME=$APP_NAME-slug
    [email protected]:$APP_NAME.git
    [email protected]:$PIPELINE_APP_NAME.git
    WORKERS_COUNT=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # configure pipeline deploy https://devcenter.heroku.com/articles/labs-pipelines
    if test $(heroku apps | grep $PIPELINE_APP_NAME -c) -gt 0; then
    echo "Using existing pipeline $PIPELINE_APP_NAME"
    git remote add pipeline $HEROKU_PIPELINE_REMOTE
    else
    heroku apps:create $PIPELINE_APP_NAME --remote pipeline
    heroku labs:enable pipelines --app $PIPELINE_APP_NAME
    fi
    heroku plugins:install git://github.com/heroku/heroku-pipeline.git
    heroku pipeline:add $APP_NAME --app $PIPELINE_APP_NAME
    heroku pipeline --app $PIPELINE_APP_NAME

    # configure app and check for db changes
    git remote add heroku $HEROKU_APP_REMOTE
    git fetch heroku
    MIGRATION_CHANGES=$(git diff $CIRCLE_SHA1 heroku/master --name-only -- db | wc -l)
    echo "$MIGRATION_CHANGES db changes since last deploy."

    # use pipeline to prepare a slug to deploy
    git push pipeline $CIRCLE_SHA1:refs/heads/master

    DEPLOY_START=`date +%s`

    # migrations require downtime so enter maintenance mode
    if test $MIGRATION_CHANGES -gt 0; then
    heroku maintenance:on --app $APP_NAME

    # Make sure workers are not running during a migration
    heroku scale worker=0 --app $APP_NAME
    fi

    # promote the compiled slug
    heroku pipeline:promote --app $PIPELINE_APP_NAME

    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku scale worker=$PREV_WORKERS --app $APP_NAME
    fi

    heroku run rake cache:flush --app $APP_NAME
    heroku maintenance:off --app $APP_NAME

    DEPLOY_END=`date +%s`
    ELAPSED=$(( $DEPLOY_END - $DEPLOY_START ))

    # HACK!
    # Pipelines do not update the git repository on downstream apps.
    #
    # In order to be able to diff for db changes against the app overwrite the pipeline
    # deploy with a git push of the same commit.
    #
    # Since this we already ran any required migrations this can always be a
    # zero-downtime deploy we don't need to enable maintenance mode and are no longer
    # sensetive to long asset precompilation times or other delays.
    #
    # We could remove this if we want to maintain a persistent pipeline app and always
    # diff against that app to determine if db changes exist. Alternately we might
    # be able to parse `heroku pipeline:diff` output for commit hashes and check for
    # db changes in each commit.
    git push heroku $CIRCLE_SHA1:refs/heads/master -f

    # remove the pipeline app
    heroku apps:destroy --app $PIPELINE_APP_NAME --confirm $PIPELINE_APP_NAME

    echo "Deploy completed!"
    if test $MIGRATION_CHANGES -gt 0; then
    echo " $ELAPSED seconds in maintenance mode."
    else
    echo " $ELAPSED seconds, without maintenance mode."
    fi
  7. Jonah revised this gist Jul 19, 2013. 1 changed file with 12 additions and 3 deletions.
    15 changes: 12 additions & 3 deletions heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,7 @@ heroku maintenance:off --app $APP_NAME

    DEPLOY_END=`date +%s`
    ELAPSED=$(( $DEPLOY_END - $DEPLOY_START ))
    echo "Deploy complete in $ELAPSED"

    # HACK!
    # Pipelines do not update the git repository on downstream apps.
    #
    @@ -62,8 +62,17 @@ echo "Deploy complete in $ELAPSED"
    # sensetive to long asset precompilation times or other delays.
    #
    # We could remove this if we want to maintain a persistent pipeline app and always
    # diff against that app to determine if db changes exist.
    # diff against that app to determine if db changes exist. Alternately we might
    # be able to parse `heroku pipeline:diff` output for commit hashes and check for
    # db changes in each commit.
    git push heroku $CIRCLE_SHA1:refs/heads/master -f

    # remove the pipeline app
    heroku apps:destroy --app $PIPELINE_APP_NAME --confirm $PIPELINE_APP_NAME
    heroku apps:destroy --app $PIPELINE_APP_NAME --confirm $PIPELINE_APP_NAME

    echo "Deploy completed!"
    if test $MIGRATION_CHANGES -gt 0; then
    echo " $ELAPSED seconds in maintenance mode."
    else
    echo " $ELAPSED seconds, without maintenance mode."
    fi
  8. Jonah revised this gist Jul 19, 2013. 1 changed file with 47 additions and 6 deletions.
    53 changes: 47 additions & 6 deletions heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,32 @@
    #!/bin/sh -e
    APP_NAME=$1
    PIPELINE_APP_NAME=$APP_NAME-slug
    [email protected]:$APP_NAME.git
    [email protected]:$PIPELINE_APP_NAME.git
    WORKERS_COUNT=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    git remote add heroku [email protected]:$APP_NAME.git
    # configure pipeline deploy https://devcenter.heroku.com/articles/labs-pipelines
    if test $(heroku apps | grep $PIPELINE_APP_NAME -c) -gt 0; then
    echo "Using existing pipeline $PIPELINE_APP_NAME"
    git remote add pipeline $HEROKU_PIPELINE_REMOTE
    else
    heroku apps:create $PIPELINE_APP_NAME --remote pipeline
    heroku labs:enable pipelines --app $PIPELINE_APP_NAME
    fi
    heroku plugins:install git://github.com/heroku/heroku-pipeline.git
    heroku pipeline:add $APP_NAME --app $PIPELINE_APP_NAME
    heroku pipeline --app $PIPELINE_APP_NAME

    # configure app and check for db changes
    git remote add heroku $HEROKU_APP_REMOTE
    git fetch heroku
    MIGRATION_CHANGES=$(git diff HEAD heroku/master --name-only -- db | wc -l)
    MIGRATION_CHANGES=$(git diff $CIRCLE_SHA1 heroku/master --name-only -- db | wc -l)
    echo "$MIGRATION_CHANGES db changes since last deploy."

    # use pipeline to prepare a slug to deploy
    git push pipeline $CIRCLE_SHA1:refs/heads/master

    PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')
    DEPLOY_START=`date +%s`

    # migrations require downtime so enter maintenance mode
    if test $MIGRATION_CHANGES -gt 0; then
    @@ -15,8 +36,8 @@ if test $MIGRATION_CHANGES -gt 0; then
    heroku scale worker=0 --app $APP_NAME
    fi

    # deploy code changes (and implicitly restart the app and any running workers)
    git push heroku $CIRCLE_SHA1:refs/heads/master
    # promote the compiled slug
    heroku pipeline:promote --app $PIPELINE_APP_NAME

    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    @@ -25,4 +46,24 @@ if test $MIGRATION_CHANGES -gt 0; then
    fi

    heroku run rake cache:flush --app $APP_NAME
    heroku maintenance:off --app $APP_NAME
    heroku maintenance:off --app $APP_NAME

    DEPLOY_END=`date +%s`
    ELAPSED=$(( $DEPLOY_END - $DEPLOY_START ))
    echo "Deploy complete in $ELAPSED"
    # HACK!
    # Pipelines do not update the git repository on downstream apps.
    #
    # In order to be able to diff for db changes against the app overwrite the pipeline
    # deploy with a git push of the same commit.
    #
    # Since this we already ran any required migrations this can always be a
    # zero-downtime deploy we don't need to enable maintenance mode and are no longer
    # sensetive to long asset precompilation times or other delays.
    #
    # We could remove this if we want to maintain a persistent pipeline app and always
    # diff against that app to determine if db changes exist.
    git push heroku $CIRCLE_SHA1:refs/heads/master -f

    # remove the pipeline app
    heroku apps:destroy --app $PIPELINE_APP_NAME --confirm $PIPELINE_APP_NAME
  9. Jonah revised this gist Jul 16, 2013. 2 changed files with 21 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions circle.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    test:
    override:
    - bundle exec rspec spec

    deployment:
    acceptance:
    branch: master
    commands:
    - ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>:
    timeout: 300
    staging:
    branch: staging
    commands:
    - ./script/heroku_deploy.sh <STAGING_HEROKU_APP>:
    timeout: 300
    production:
    branch: production
    commands:
    - ./script/heroku_deploy.sh <PRODUCTION_HEROKU_APP>:
    timeout: 300
    1 change: 1 addition & 0 deletions heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    APP_NAME=$1

    git remote add heroku [email protected]:$APP_NAME.git
    git fetch heroku
    MIGRATION_CHANGES=$(git diff HEAD heroku/master --name-only -- db | wc -l)

    PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')
  10. Jonah created this gist Jul 11, 2013.
    27 changes: 27 additions & 0 deletions heroku_deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/bin/sh -e
    APP_NAME=$1

    git remote add heroku [email protected]:$APP_NAME.git
    MIGRATION_CHANGES=$(git diff HEAD heroku/master --name-only -- db | wc -l)

    PREV_WORKERS=$(heroku ps --app $APP_NAME | grep "^worker." | wc -l | tr -d ' ')

    # migrations require downtime so enter maintenance mode
    if test $MIGRATION_CHANGES -gt 0; then
    heroku maintenance:on --app $APP_NAME

    # Make sure workers are not running during a migration
    heroku scale worker=0 --app $APP_NAME
    fi

    # deploy code changes (and implicitly restart the app and any running workers)
    git push heroku $CIRCLE_SHA1:refs/heads/master

    # run database migrations if needed and restart background workers once finished
    if test $MIGRATION_CHANGES -gt 0; then
    heroku run rake db:migrate db:seed --app $APP_NAME
    heroku scale worker=$PREV_WORKERS --app $APP_NAME
    fi

    heroku run rake cache:flush --app $APP_NAME
    heroku maintenance:off --app $APP_NAME