Skip to content
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

Pre-deploy hooks #20

Open
judofyr opened this issue Jun 15, 2011 · 5 comments
Open

Pre-deploy hooks #20

judofyr opened this issue Jun 15, 2011 · 5 comments

Comments

@judofyr
Copy link

judofyr commented Jun 15, 2011

I'm interested in running pre-deploy hooks:

namespace :deploy do
  namespace :staging do
    task :pre_deploy do
      Rake::Task['deploy:web:disable'].invoke if changes?('db/schema.rb') && role?(:web)
    end

    task :post_deploy do
      if changes?('db/schema.rb')
        Rake::Task['db:migrate'].invoke if role?(:db)
        Rake::Task['depoy:web:enable'].invoke if role?(:web)
      end
    end
  end
end

The pre-deploy hook should run with:

  • Previous version checked out
  • Newest version available in origin/
  • .whiskey_disk-files updated
@rick
Copy link
Member

rick commented Jun 15, 2011

Thanks, Magnus --
I'll try to look at this on the plane back from SF this week.
Rick

@rick
Copy link
Member

rick commented Jun 20, 2011

I didn't get a chance to get to this on the plane. A couple of clarifying questions now that I'm thinking more about it:

I read your pre-deploy state as:

  • working from the prior version
  • having already done a git fetch for the main repo

I'm not sure which .whiskey_disk-files you're asking for -- do you mean the files which track changes? For a single repo this would be possible (as that's deducible via git from the hashes of the current HEAD and the new origin/ HEAD), but for information from the other repositories it would be harder (as that information comes from applying those files, currently via rsync).

I'm mentally walking myself through the "business value" of the three preconditions. Having the previous version checked out seems obvious to me (and would be the state I think most people would expect the checkout to be in); having origin/ available (i.e., post-fetch) seems reasonable, as then one could do one's own arbitrary comparisons as to state. If it's changes files we're discussing in #3 then that might also be useful, it just happens to be (quite?) a bit more difficult.

Thoughts?

Rick

@judofyr
Copy link
Author

judofyr commented Jun 20, 2011

Let me rephrase my third "requirement": I want to be able to use changes? in my pre-deploy hook.

Also, when I think about it, shouldn't the pre-deploy hooks run on all the machines before any of them start on the deployment? Ugh, this seems harder than I thought :/

@rick
Copy link
Member

rick commented Jun 20, 2011

Gotcha. I'm doing some work that will allows #changes? to work in the pre-deploy hooks. The synchronization bit is on the radar for other reasons, but may take a bit to get done.

@judofyr
Copy link
Author

judofyr commented Jun 21, 2011

Great. And thanks for some great work on whiskey_disk :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants