Github Action - 将评论添加到 PR 时接收事件?

Mar*_*rty 4 github-actions

当评论添加到该 PR 时,有没有办法让 Github Action 在 PR 上触发?我创建了一个 Github 操作,它将在 PR(创建等)上发生的各种事件上触发。我还没有弄清楚的一个是添加评论时的触发器。我在这里没有看到任何表明它受支持的内容:

https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows

我错过了什么吗?

pet*_*ans 5

GitHub 拉取请求实际上是问题。所以你要找的事件是issue_comment.

on:
  issue_comment:
    types: [created]
Run Code Online (Sandbox Code Playgroud)

您可以过滤掉这样的拉取请求评论事件:

on:
  issue_comment:
    types: [created]
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - name: Execute for pull request comments only
        if: github.event.issue.pull_request
        run: echo "This is a pull request comment event"
Run Code Online (Sandbox Code Playgroud)

  • 工作流必须提交到 master 分支才能触发“issue_comment”事件。请参阅文档,其中指出事件的“GITHUB_SHA”是“默认分支上的最后一次提交”。 (4认同)