jakehow (owner)

Revisions

gist: 18534 Download_button fork
public
Public Clone URL: git://gist.github.com/18534.git
Embed All Files: show embed
basecamp-notify-on-deploy.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
desc "Discover previous revision"
task :set_previous_revision do
  previous_revision = ""
  run "tail -2 #{deploy_to}/revisions.log" do |ch, stream, out|
    previous_revision = out.split[3]
  end
  set :previous_revision, previous_revision
end
 
desc "Send release notes for latest revision via Basecamp"
task :send_release_notes do
  require 'lib/basecamp'
  BC_URL = 'yoururl'
  BC_USR = 'username'
  BC_PWD = 'pass'
  PROJECT_ID = 1111
  CATEGORY_ID = 2222
  
  system "svn log -r HEAD:#{previous_revision} #{repository} > /tmp/rel.notes"
  notes = IO.read("/tmp/rel.notes")
  session = Basecamp.new(BC_URL, BC_USR, BC_PWD)
  body = "This is an automatically generated message notifying the team of updates to the production site.\n\n" + notes
  
  #This pulls all the people from the 2 companies on this project, that way if anyone is added, no re-editing
  NOTIFY_IDS = (session.people(COMPANYID1, PROJECT_ID)+ session.people(COMPANYID2, PROJECT_ID)).map { |p| p.id }
  msg = session.post_message(PROJECT_ID,
          { :title => "New Updates Deployed to the Production Server"
            :body =>body,
            :category_id => CATEGORY_ID },
            NOTIFY_IDS )
end
 
desc "Send release notes after deploy"
task :after_deploy do
  set_previous_revision
  send_release_notes
end