From 045f27ff0baf5e4f01725a24420560fa2aca6ac8 Mon Sep 17 00:00:00 2001 From: Amy Gimma Date: Thu, 13 Aug 2015 16:41:51 -0400 Subject: [PATCH 1/2] switch to yaml --- README.md | 65 ++++++++++++++++++---------------- lib/wizarddev/heroku/deploy.rb | 3 +- sample.deploy.yml | 27 ++++++++++++++ 3 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 sample.deploy.yml diff --git a/README.md b/README.md index 7b5d13d..cf6442d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ From `rake deploy` ``` Deploys the currently checked out revision to Heroku. -Reads the project's app.json file to determine tasks for a target. +Reads the project's deploy.yml file to determine tasks for a target. Tasks include: Tag the release and pushes it to github Deploy the release to Heroku @@ -36,36 +36,39 @@ usage: rake deploy TARGET=target_name usage: rake deploy:{staging|production} ``` -## Example app.json - -This is very similar and compatible with Heroku's `app.json`. - -```json -{ - "name": "Our Cool App", - "description": "Great app to use all the time.", - "website": "https://www.ourcoolapp.com", - "heroku-environments": { - "staging": { - "app-name": "ourcoolapp-staging", - "tag-name": false, - "force-push": true, - "scripts": [ - { "cmd": "rake db:migrate", "restart": true } - ] - }, - "production": { - "app-name": "ourcoolapp-production", - "force-push": false, - "tag-name": "prod", - "scripts": [ - { "cmd": "rake db:migrate", "restart": true, "remote": true }, - { "cmd": "say 'deploy complete'"} - ] - } - }, - "source-repo": "git@github.com:wizarddevelopment/ourcoolapp.git" -} +## Example deploy.yml + +This is very similar to Heroku's `app.json` but as a yml file + +```yml +--- +name: Our Cool App +description: Great app to use all the time. +website: "https://www.ourcoolapp.com" +heroku-environments: + staging: + app-name: "ourcoolapp-staging" + tag-name: false + force-push: true + scripts: + - cmd: "rake db:migrate" + restart: true + remote: true + - cmd: "rake coolapp:do_something_on_deploy" + remote: true + production: + app-name: "ourcoolapp-production" + force-push: false + tag-name: prod + scripts: + - cmd: "rake db:migrate" + restart: true + remote: true + - cmd: "rake coolapp:do_something_on_deploy" + remote: true + - cmd: "say 'deploy complete'" +source-repo: "git@github.com:wizarddevelopment/ourcoolapp.git" + ``` diff --git a/lib/wizarddev/heroku/deploy.rb b/lib/wizarddev/heroku/deploy.rb index 150bca7..a7f670a 100644 --- a/lib/wizarddev/heroku/deploy.rb +++ b/lib/wizarddev/heroku/deploy.rb @@ -88,7 +88,7 @@ def restart end def load_config - JSON.parse(File.read('app.json')) + YAML.load_file('deploy.yml') end def source_repo @@ -116,7 +116,6 @@ def config raise "No configuration for #{target} in app.js" unless c c end - end end end diff --git a/sample.deploy.yml b/sample.deploy.yml new file mode 100644 index 0000000..7001650 --- /dev/null +++ b/sample.deploy.yml @@ -0,0 +1,27 @@ +--- +name: Our Cool App +description: Great app to use all the time. +website: "https://www.ourcoolapp.com" +heroku-environments: + staging: + app-name: "ourcoolapp-staging" + tag-name: false + force-push: true + scripts: + - cmd: "rake db:migrate" + restart: true + remote: true + - cmd: "rake coolapp:do_something_on_deploy" + remote: true + production: + app-name: "ourcoolapp-production" + force-push: false + tag-name: prod + scripts: + - cmd: "rake db:migrate" + restart: true + remote: true + - cmd: "rake coolapp:do_something_on_deploy" + remote: true + - cmd: "say 'deploy complete'" +source-repo: "git@github.com:wizarddevelopment/ourcoolapp.git" From be15ac12b9f2f4952506b6db84d4507e5851703d Mon Sep 17 00:00:00 2001 From: Amy Gimma Date: Thu, 13 Aug 2015 18:08:26 -0400 Subject: [PATCH 2/2] default yaml generator --- lib/wizarddev/heroku/tasks/yaml_generator.rb | 7 ++++++ lib/wizarddev/heroku/yaml_generator.rb | 17 +++++++++++++++ lib/wizarddev/template.yml | 23 ++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 lib/wizarddev/heroku/tasks/yaml_generator.rb create mode 100644 lib/wizarddev/heroku/yaml_generator.rb create mode 100644 lib/wizarddev/template.yml diff --git a/lib/wizarddev/heroku/tasks/yaml_generator.rb b/lib/wizarddev/heroku/tasks/yaml_generator.rb new file mode 100644 index 0000000..66dc3de --- /dev/null +++ b/lib/wizarddev/heroku/tasks/yaml_generator.rb @@ -0,0 +1,7 @@ +namespace :deployer do + desc "Creates default deploy.yml file based on ENV variables" + task :create_deploy_yaml do + YamlGenerator.create + puts "Generator Finished" + end +end diff --git a/lib/wizarddev/heroku/yaml_generator.rb b/lib/wizarddev/heroku/yaml_generator.rb new file mode 100644 index 0000000..1f09a76 --- /dev/null +++ b/lib/wizarddev/heroku/yaml_generator.rb @@ -0,0 +1,17 @@ +module YamlGenerator + def self.create + app_name = ENV["HEROKU_APP_NAME"] + deploy_name = ENV["HEROKU_DEPLOY_NAME"] + repo_name = ENV["REPO_NAME"] + app_url = ENV["APP_URL"] + + yaml_content = YAML.load_file('template.yml') + yaml_content["source-repo"] = "git@github.com:#{repo_name}.com.git" + yaml_content["website"] = app_url + yaml_content["heroku-environments"]["staging"]["app-name"] = "#{deploy_name}-staging" + yaml_content["heroku-environments"]["production"]["app-name"] = "#{deploy_name}-production" + out_file = File.new("deploy.yml", "w") + out_file.puts(yaml_content.to_yaml) + out_file.close + end +end diff --git a/lib/wizarddev/template.yml b/lib/wizarddev/template.yml new file mode 100644 index 0000000..a915ff0 --- /dev/null +++ b/lib/wizarddev/template.yml @@ -0,0 +1,23 @@ +--- +name: app_name +description: Great app to use all the time. +website: deploy_url +heroku-environments: + staging: + app-name: "deploy_name-staging" + tag-name: false + force-push: true + scripts: + - cmd: rake db:migrate + restart: true + remote: true + production: + app-name: "deploy_name-production" + force-push: false + tag-name: prod + scripts: + - cmd: rake db:migrate + restart: true + remote: true + - cmd: say 'deploy complete' +source-repo: "git@github.com:repo_name.com.git"