diff --git a/README.md b/README.md index fe4a2dd..9475b8d 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ In the auto-generated `config/deploy.rb` file, add the following line to set the set :branch, ENV["BRANCH"] || "main" ``` +Add the `write-version` task to give your project a public page at `/version.txt` with the branch name, commit SHA, and release date of the current deployment. + Some additional Capistrano-related gems our team uses: - `capistrano-passenger`: Restarts the application automatically after deployment - https://github.com/capistrano/passenger diff --git a/config/deploy.rb b/config/deploy.rb index 61abb51..906987c 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -36,5 +36,15 @@ # Default value for keep_releases is 5 # set :keep_releases, 5 +desc "Write the current version to public/version.txt" +task :write_version do + on roles(:app), in: :sequence do + within repo_path do + execute :tail, "-n1 ../revisions.log > #{release_path}/public/version.txt" + end + end +end +after "deploy:log_revision", "write_version" + # Uncomment the following to require manually verifying the host key before first deploy. # set :ssh_options, verify_host_key: :secure