LoginSignup
1
1

More than 5 years have passed since last update.

capistrano3 デプロイ時に git revision をファイルに出力する

Last updated at Posted at 2015-09-12

追記

この記事の内容を gem として作り、rubygems に登録しました。

以下のサイトを参考にしました。

バージョン

version
capistrano 3.3.5

参考

capistrano のタスクを作成する

タスク部分のみで他は省略しています。

https://github.com/railsconfig/config を利用しているので、
出力先は config/settings.local.yml にしています。

config/deploy.rb
namespace :deploy do

  desc 'Save current revision'
  task :save_current_revision do
    on roles(:app), in: :groups, limit: 10, wait: 5 do
      within release_path do
        execute :echo, "'revision: #{fetch :current_revision}' > config/settings.local.yml"
      end
    end
  end

  before :updated, :save_current_revision
end

これで view に表示することもできます。erb の場合は以下です。

(rev.<%= Settings.revision %>)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1