How to stop github actions workflow to trigger when the pull request is from dependabot-preview? · community · Discussion #26079 (original) (raw)
Hi @riprasad,
Image pull request is created from compared branch ‘depbot’ to base branch. Typically workflow can be skipped with below methods:
- Use on.pull_request.branches/branches-ignore to limit the base branch. code sample as below:
on:
pull_request:
branches-ignore:
- master # pull request to master branch, event will NOT be triggered.
- Add if expression in worklfow yaml, eg: skip the job if pull request comes from user dephot. The limitation is the workflow will be listed in the actions tab but the job is skipped.
on: [pull_request]
jobs:
job1:
if: github.actor!= 'depbot' # ignore the pull request which comes from user depbot.
Note: you can change the if expression according to your needs.
- If you don’t like whatever pull_request from depbot branch, you can comment out the pull_request event or delete it from yaml file, or even disable all github actions from repo setting- Actions tab.
You can pick one according to your needs.
Thanks.
You must be logged in to vote
0 replies
Correction on the second point (correct actor name):-
on: [pull_request]
jobs:
job1:
if: github.actor!= 'dependabot-preview[bot]' # ignore the pull request which comes from user depbot.
You must be logged in to vote
0 replies
I'm not sure when/where this set, but our dependabot actor's name does not include the 'preview' portion.
on: [pull_request]
jobs:
job1:
if: github.actor!= 'dependabot[bot]' # ignore the pull request which comes from user depbot.
You must be logged in to vote
0 replies
Does dependabot always create a branch named dependabot/*? If so, this might work better in a workflow with lots of jobs:
on:
pull_request:
branches-ignore:
- dependabot/*
You must be logged in to vote
1 reply
@mconigliaro : Hi
Apparently, from what I see in the GH Action documentation, this branches-ignore feature only applies to the PR's targeted branche, not the source one.