3
votes

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?

2

2 Answers

4
votes

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

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.