Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Github Action workflow, only run when desired

I have some very expensive benchmarks/tests which I'd only like to run on some PRs, not all. Is there a way to do this with github actions?

like image 946
sharks Avatar asked Nov 28 '25 22:11

sharks


1 Answers

Yes, there are several ways. Most of the workflow triggers can be further specified through "Activity Types". For Pull Requests, they are:

  • assigned
  • unassigned
  • labeled
  • unlabeled
  • opened
  • edited
  • closed
  • reopened
  • synchronize
  • ready_for_review
  • locked
  • unlocked
  • review_requested
  • review_request_removed

(Docs as Source)

Now, you could run the workflow only for PRs matching a certain pattern:

on:
  pull_request:
    branches:
      - 'benchmark/**'

You could also do it with labels:

on:
  pull_request: labeled
...
jobs:
  check-label:
    if: ${{ github.event.label.name == 'benchmark' }}
...

And of course you can also always use manual triggers only:

on: workflow_dispatch
like image 61
Meiswjn Avatar answered Nov 30 '25 13:11

Meiswjn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!