I finally got to the bottom of this one!
I had a step set to run before deployment:
before "deploy", "maintenance:enable"
This maintenance step (correctly) sets up maintenance mode on the existing site (in the example above, my 2013 one).
However, the maintenance task was referring to the previous release by using the latest_release
variable. Since the step was running before deployment, latest_release
did indeed refer to the 2013 release. However, once latest_release
has been used, its value is set for the rest of the deployment run - so it remained set to the 2013 release!
I therefore resolved this by changing the maintenance code so that it didn't use the latest_release
variable. I used current_release
instead (which doesn't seem to have this side-effect). However, another approach would be to define your own variable which gets its value in the same way as latest_release
would:
set :prev_release, exists?(:deploy_timestamped) ? release_path : current_release
I worked out how latest_release
was being set by looking in the Capistrano code. In my environment, I could find this by doing bundle show capistrano
(since it was installed with bundler), but the approach will differ for other setups.
Although the reason for my problem was quite specific, my approach may help others: I created an entirely vanilla deployment following the Capifony instructions and gradually added in features from my old deployment until it broke!