According to the documentation, you can't achieve want you want at the workflow level, as it's based on base branches
.
Therefore, those implementations below won't work.
on:
pull_request:
branches:
- 'master' # matches refs/heads/master
- '!depbot' # excludes refs/heads/depbot
Or
on:
pull_request:
branches-ignore:
- 'depbot' # ignore refs/heads/depbot
EDITED ANSWER
Workaround
A solution could be to use a setup job
checking the github.head_ref
context variable, and setting an output that would be used in an expression to run the following jobs if the condition is fulfilled.
Something like this:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
condition: ${{ steps.condition.outputs.condition }}
steps:
- id: condition
run: |
if [[ ${{ github.head_ref }} == *"depbot"* ]]; then
echo "condition=true" >> $GITHUB_OUTPUT
else
echo "condition=false" >> $GITHUB_OUTPUT
fi
other-job:
needs: [setup]
runs-on: ubuntu-latest
if: ${{ needs.setup.outputs.condition }} == 'true'
steps:
[ ... ]
The thing is, this workflow will always trigger, it will just not perform the desired operations if the condition isn't fulfilled.