问题
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?
回答1:
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:
...
回答2:
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.
来源:https://stackoverflow.com/questions/61788540/only-run-github-actions-manually-while-blocking-pull-request