Notify Shipyrd with the Ruby gem
For Kamal-deployed Rails (or any Ruby) apps. Add the gem, drop in two hook files, ship.
What it does
The shipyrd gem wires into Kamal’s lifecycle hooks. Kamal calls the hook scripts you create in .kamal/hooks/, the gem reads the standard KAMAL_* environment variables (destination, version, performer, runtime), and POSTs to Shipyrd’s API. The canonical setup uses pre-deploy and post-deploy; the gem also accepts pre-connect and pre-build if you want to record those phases.
Setup
-
Add the gem to your Gemfile.
bundle add shipyrd -
Add
SHIPYRD_API_KEYto your Kamal secrets so it’s available to hooks at deploy time.# config/deploy.yml env: secret: - SHIPYRD_API_KEYSet the value in
.kamal/secrets(or your secret manager of choice). -
Create the two hook files. Both must be executable.
# .kamal/hooks/pre-deploy #!/usr/bin/env ruby require 'shipyrd' Shipyrd::Client.new.trigger('pre-deploy')# .kamal/hooks/post-deploy #!/usr/bin/env ruby require 'shipyrd' Shipyrd::Client.new.trigger('post-deploy')chmod +x .kamal/hooks/pre-deploy .kamal/hooks/post-deploy -
Deploy. The hooks fire automatically.
kamal deploy
What gets recorded
The gem reads these from Kamal’s environment, so you don’t have to pass anything explicitly:
KAMAL_DESTINATION— environment (production,staging, etc.)KAMAL_PERFORMER— who’s deploying (see below)KAMAL_VERSION/KAMAL_SERVICE_VERSION— the image tagKAMAL_RUNTIME— deploy duration (post-deploy only)- The first 90 characters of the most recent commit message
Override any of these with a SHIPYRD_-prefixed env var (e.g. SHIPYRD_PERFORMER).
Performer matching
The performer value decides which Shipyrd user “owns” a deploy — it matters for environment locking and Slack mentions. It must match one of:
- A GitHub profile URL — the gem sets this automatically if you have
gh config set -h github.com user yournameconfigured locally. - An email address — must match an email on a Shipyrd account in your team.
If neither matches, the deploy still records but isn’t attributed to a user.
Verify it worked
Run kamal deploy. You should see the hooks fire in Kamal’s output, then the deploy appears in your Shipyrd timeline within a second or two.
Related
- Docker container — run the same gem in non-Ruby projects via Docker
- Plain HTTP — for non-Kamal pipelines
- Deploy locks — performer matching is what makes locks per-user