Make it possible to let branch deletion wait until environment has stopped

Problem to solve

Sometimes the stop action of an environment needs to have access to a branch. When a branch gets deleted, the stop action is automatically triggered. In that case we should allow waiting for the stop action to complete before the branch is deleted.

Further details

see also discussion in https://gitlab.com/gitlab-org/gitlab-ce/issues/45658

Proposal

  • always run stop action first and then delete branch (this will delay branch deletion significantly)

or

  • pass SHA of last commit on the deleted branch to the stop action (this will work until the next run of git gc)

or

  • add configuration to run stop actions before branch deletions—in project settings or .gitlab-ci.yml