Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only run GitHub Actions manually while blocking Pull Request

I have a set of GitHub Actions configured to block pull requests from being merged until the Actions complete successfully. However, every time a new commit is pushed to a PR, the Actions are run again, which can be very wasteful if the author is not yet ready to merge, and intends to make future changes. Is there any way to have a GitHub Action still block a PR being merged but also not run the Action automatically?

like image 254
joshlf Avatar asked Oct 29 '25 08:10

joshlf


2 Answers

With this recent update you can now convert pull requests back to draft status. So you could do that when you need to make changes and disable the CI for drafts. Then convert the draft to a pull request after the changes are complete to rerun CI.

on: pull_request
jobs:
  build:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    steps:
      ...
like image 163
peterevans Avatar answered Oct 31 '25 06:10

peterevans


One workaroound would be for the Action to look for a specific comment (for example: "[TO MERGE]: this commit is about ...), and:

  • return immediately if '[TO MERGE]' is not found, minimizing the action overhead on each commit
  • go on with checks, if '[TO MERGE]' is found.
like image 44
VonC Avatar answered Oct 31 '25 06:10

VonC



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!