How to stop github actions workflow to trigger when the pull request is from dependabot-preview?

Hi Team,

I have a workflow that gets triggered whenever somebody raises a pull request. However, I would not like the workflow to get triggered whenever their is an automated pull request from the dependabot-preview bot. How can I achieve that ?

Hi @riprasad,

Image pull request is created from compared branch ‘depbot’ to base branch. Typically workflow can be skipped with below methods:

  1. 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.
  1. 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.

  1. 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.

1 Like

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.