Can I restrict a Bitbucket Manual (custom) Pipeline to a specific Branch?

I’m looking for a way to combine two features of Bitbucket pipelines.

  1. Restrict a pipeline to a particular branch pattern (e.g. release/*)
  2. Construct a pipeline to be triggered by Manual selection.

I’ve implemented these separately for different pipelines, but I’m looking for a way to combine these.

We have an automated pipeline which pushes developer code through to staging. This operates on the main branch and triggers automatically, whenever code is committed onto this branch. As such -

  branches:
    main:
      - step:
          condition:
      etc...

This triggers automatically on the main branch.

I have a separate pipeline which is intended to operate on any release branch. This pipeline triggers manually. As such -

  custom:
    production-deployment:  
      - step:
      etc...

This pipeline will push an approved release through to production. This pipeline will be triggered manually by selecting a release branch and selecting the pipeline. I’ve secured the release branches so a nominal degree of security is implemented on the repository. (Unfortunately, Bitbucket doesn’t enforce security on pipelines, only on branches.) To complete the picture, I’d like to define the pipeline so that is will only operate if the branch on which it is requested fits the pattern of release/*. (If I can’t do that, then the branch security is useless since someone might inadvertently trigger the pipeline for a non-release branch and push code which is not approved for release through to production.) I’m looking for a code snippet which will impose this restriction either declaratively, or a code snippet which will interrogate the current branch and then raise an exception if the current branch does not fit the expected pattern. Thanks for any advice which you can provide.