Skip to content

Commit

Permalink
Set auto-deploy for Heroku suspended apps
Browse files Browse the repository at this point in the history
Previously, the Circle CI config for suspended applications enabled
automatic deployments for all apps. Given that the `bin/deploy` script
is only generated for apps suspended with the `--heroku true` flag, this
led to builds failing on the deployment step due to the script not being
found.

This PR adds the deployment command to `circle.yml` only when an app is
suspended with the Heroku options. There are still manual setup steps
required, such as setting the Heroku API and SSH key but those are
clearly indicated by the error messages on Circle CI and makes
Suspenders defaults more "out-of-the-box" friendly.

[fixes #610]
  • Loading branch information
pedrosmmoreira authored and tute committed Oct 5, 2015
1 parent 712dd93 commit 6ac8874
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/suspenders/app_builder.rb
Expand Up @@ -400,6 +400,20 @@ def provide_deploy_script
run "chmod a+x bin/deploy"
end

def configure_automatic_deployment
staging_remote_name = heroku_app_name_for("staging")
deploy_command = <<-YML.strip_heredoc
deployment:
staging:
branch: master
commands:
- git remote add staging git@heroku.com:#{staging_remote_name}.git
- bin/deploy staging
YML

append_file "circle.yml", deploy_command
end

def create_github_repo(repo_name)
path_addition = override_path_for_tests
run "#{path_addition} hub create #{repo_name}"
Expand Down
1 change: 1 addition & 0 deletions lib/suspenders/generators/app_generator.rb
Expand Up @@ -175,6 +175,7 @@ def create_heroku_apps
build :set_heroku_remotes
build :set_heroku_rails_secrets
build :provide_deploy_script
build :configure_automatic_deployment
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/features/heroku_spec.rb
Expand Up @@ -35,6 +35,18 @@

expect(readme).to include("./bin/deploy staging")
expect(readme).to include("./bin/deploy production")

circle_yml_path = "#{project_path}/circle.yml"
circle_yml = IO.read(circle_yml_path)

expect(circle_yml).to include <<-YML.strip_heredoc
deployment:
staging:
branch: master
commands:
- git remote add staging git@heroku.com:#{app_name}-staging.git
- bin/deploy staging
YML
end

it "suspends a project with extra Heroku flags" do
Expand Down

0 comments on commit 6ac8874

Please sign in to comment.