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

Cap task to write public text file with SHA of last deploy #32

Merged
merged 3 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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