Skip to content

switch to yaml #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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": "[email protected]: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: "[email protected]:wizarddevelopment/ourcoolapp.git"

```


Expand Down
3 changes: 1 addition & 2 deletions lib/wizarddev/heroku/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -116,7 +116,6 @@ def config
raise "No configuration for #{target} in app.js" unless c
c
end

end
end
end
7 changes: 7 additions & 0 deletions lib/wizarddev/heroku/tasks/yaml_generator.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions lib/wizarddev/heroku/yaml_generator.rb
Original file line number Diff line number Diff line change
@@ -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"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many ENV variables


yaml_content = YAML.load_file('template.yml')
yaml_content["source-repo"] = "[email protected]:#{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
23 changes: 23 additions & 0 deletions lib/wizarddev/template.yml
Original file line number Diff line number Diff line change
@@ -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: "[email protected]:repo_name.com.git"
27 changes: 27 additions & 0 deletions sample.deploy.yml
Original file line number Diff line number Diff line change
@@ -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: "[email protected]:wizarddevelopment/ourcoolapp.git"