Start Action on a Pull Request based on the source branch naming convention OR pull request title

I have a use-case where I would like to be able to control for which Pull Requests I should start a GitHub action. Generally speaking based on the source branch naming convention I would like to decide whether I start a github action or not. Why?
I have a relatively expensive build, deploy & test workflow that I’ve mananged to fully automate for people.
This worklow should be fired off only when neccessary, namely: when someone created a pull request for source branch:
I want to achieve here overall ephemeral environments- which are created as soon as people raise a PR - so that QA folks can have an environment up and running with the code related to the PR.
On the other hand - sometimes people might be doing changes that don’t require spinning up an ephemeral env for that pull request, the rule I wanna have here is basically that the source branch is not!:
Can’t find a way to do that.
Alternatively I was thinking about introducing some form of convention for the Pull Request title itself, e…g.
if Pull Request title starts with “no_env” then don’t build an ephemeral environment.
Did you face a similar use case? Some sensible ideas for this?

There is the branches or branches-ignore option which, when used on pull_request or pull_request_target, will only start the action when the target branch of the PR is the one specified or NOT the one specified in the branches-ignore case.


name: Auto approve

    - 'master'

    runs-on: ubuntu-latest
    - uses: hmarr/auto-approve-action@v2
      if: == 'dependabot[bot]' || == 'dependabot-preview[bot]'
        github-token: "${{ secrets.GITHUB_TOKEN }}"

This setup would only trigger the auto-approve action, if the PR targets the master branch directly.

I hope this answers your question. :slight_smile: