Running (before|after)_deploy for selected deploys

I have an app that has multiple deploy targets. 2 are branch-based, 1 is tag-based. The one that is tag-based is a bit more official and needs to do a bit of extra work both before and after the deploy, but I can’t find a clear path to do that. AFAICT, before_deploy and after_deploy are an array of CLI instructions. Is there a way to run those only for the tag build that I’m not seeing?

I’ve implemented this solution for now. Would love to know whether there’s a more idiomatic way.