Only run GitHub Actions manually while blocking Pull Request

只愿长相守 提交于 2021-02-16 20:08:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!