There's currently no way to specify a condition on the head branch name at the workflow initialisation (on
) level. Both pull_request
and pull_request_target
use the base branch (the one being merged to) as the branch name checked against in the on.<pull_request|pull_request_target>.<branches|branches-ignore>
, even though the ref for the pull_request_target
is the head branch and not the base branch.
The docs for the pull_request
event suggest that the only available way to limit on the head branch is to if
the job.
To run a job based on the pull request's head branch name (as opposed to the pull request's base branch name), use the github.head_ref
context in a conditional. For example, this workflow will run whenever a pull request is opened, but the run_if
job will only execute if the head of the pull request is a branch whose name starts with releases/
:
on:
pull_request:
types:
- opened
jobs:
run_if:
if: startsWith(github.head_ref, 'releases/')
runs-on: ubuntu-latest
steps:
- run: echo "The head of this PR starts with 'releases/'"
In your case you would have to if
every job in the workflow to run on;
if: github.head_ref != 'release/master'
Or add it to existing if
's you already have;
if: >-
${{ github.head_ref != 'release/master' && (
...) }}