如果有注释,运行github workflow



我想通过推送更新我的拉请求,检查是否有评论并运行工作流

name: Update
on:
pull_request:
types: [synchronize]
branches:
- develop
jobs:
update:
name: Update
if: contains(github.event.pull_request_comment.comment, 'Here is a comment:')

输入图片描述

我想在推送新内容之前检查是否已经创建了注释

我知道github.event。pull_request_comment是创建评论之后的东西但我需要检查它是否已经创建

我会尝试使用此操作peter-evans/find-comment来检查您的PR评论中的字符串,然后在您的if检查中使用该字符串。

jobs:
check-comment:
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.fc.outputs.comment-id }}
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: 'Here is a comment:'
run-other-workflow:
needs: [check-comment]
uses: ./other-workflow.yml
if: ${{ needs.check-comment.outputs.comment-id != 0 }}

第一个作业将在您的PR中找到注释(如果它存在),第二个作业将在找到该注释时运行。ref

👋

不确定它是否会工作,但你可以使用issue_comment webhook来触发工作流?

您可以指定它,以便仅创建注释触发工作流。