Skip to content

Commit

Permalink
working deploy hook for heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
Visnu Pitiyanuvath committed Aug 27, 2010
1 parent 264aa82 commit f721cbd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
9 changes: 4 additions & 5 deletions models/models.coffee
Expand Up @@ -52,6 +52,7 @@ class Team

beforeSave: (fn) ->
@generateSlug =>
@generateDeploySlugs()
threads = @members.length
return fn() unless threads
for member in @members
Expand Down Expand Up @@ -93,11 +94,9 @@ class Team
else
@generateSlug fn, @slug + '-' # try with another -

toJoyentSlug: ->
@slug.replace(/^(\d)/, 'ko-$1')

toHerokuSlug: ->
'nko-' + @slug.replace(/_/g, '-').substring(0, 26)
generateDeploySlugs: ->
@joyentSlug = @slug.replace(/^(\d)/, 'ko-$1')
@herokuSlug = 'nko-' + @slug.replace(/_/g, '-').substring(0, 26)

nko.Team = Team

Expand Down
29 changes: 13 additions & 16 deletions nodeko.coffee
Expand Up @@ -169,7 +169,6 @@ get '/teams/:id', ->
@team = team
@title = @team.name
@editAllowed = @canEditTeam team
@url = @team.url || "http://#{@team.application}.nodeknockout.com"

people = team.members or []
@members = _.select people, (person) -> person.name
Expand Down Expand Up @@ -374,21 +373,19 @@ put '/people/:id', ->
@redirectToTeam person

post '/deploys', ->
# , body:
# { user: 'visnupx@gmail.com'
# , head: '87eaeb6'
# , app: 'visnup-nko'
# , url: 'http://visnup-nko.heroku.com'
# , git_log: ''
# , prev_head: ''
# , head_long: '87eaeb69d726593de6a47a5f38ff6126fd3920fa'
# }
[ slug, deployedTo ] =
if app = @req.param('app')
[ app.replace(/^nko-/, ''), 'heroku' ]
else
[ @req.param('url').replace(/^http:\/\/(ko-)?|\.no\.de$/g, ''), 'joyent' ]
Team.fromParam slug, (error, team) =>
# user: 'visnupx@gmail.com'
# head: '87eaeb6'
# app: 'visnup-nko'
# url: 'http://visnup-nko.heroku.com'
# git_log: ''
# prev_head: ''
# head_long: '87eaeb69d726593de6a47a5f38ff6126fd3920fa'
# TODO don't let anyone post here
sys.log sys.inspect(@req)
query = {}
deployedTo = if /\.no\.de$/.test(@req.param('url')) then 'joyent' else 'heroku'
query[deployedTo + 'Slug'] = @req.param('app')
Team.first query, (error, team) =>
if team
team.url = @req.param('url')
team.lastDeployedTo = deployedTo
Expand Down
8 changes: 4 additions & 4 deletions views/teams/show.html.haml
@@ -1,7 +1,7 @@
%h1= ctx.team.application || ctx.team.name
.clear

- if (!ctx.team.url && ctx.canEditTeam(ctx.team))
- if (ctx.canEditTeam(ctx.team))
.deploy
- if (ctx.team.lastDeployedTo)
%h3.green
Expand Down Expand Up @@ -45,7 +45,7 @@
%li
%code
git remote add joyent \\<br/> ssh://node@
= ctx.team.toJoyentSlug() + '.no.de/repo'
= ctx.team.joyentSlug + '.no.de/repo'
%li
%code git push joyent master
%td
Expand All @@ -56,7 +56,7 @@
%li
%code
git remote add heroku \\<br/> git@heroku.com:
= ctx.team.toHerokuSlug() + '.git'
= ctx.team.herokuSlug + '.git'
%li
%code git push heroku master

Expand All @@ -67,7 +67,7 @@
%img{ src: '/images/blank.png' }
.description
%h2
%a{ href: ctx.url }= ctx.url.replace(/^http:\/\//, '')
%a{ href: ctx.team.url }= ctx.team.application
%h4= 'by ' + ctx.team.name
- if (ctx.isAdmin)
%a.button.important{ href: '#your_vote' } Vote &raquo;
Expand Down

0 comments on commit f721cbd

Please sign in to comment.