【发布时间】:2021-05-27 05:31:48
【问题描述】:
我正在尝试构建一个 GitHub 工作流程,该工作流程在将 PR 创建到某个存储库时执行简单的预提交检查,并在某些检查失败时触发消息。 问题是我希望该消息尽可能具体,因此,该消息必须包含阻止检查成功的错误。 为了执行预提交检查,我使用pre-commit action,为了自动化消息,我使用官方操作github-script。
由于我使用 pre-commit 操作 来执行检查,我认为我无法使用 set-output 解决方案来定义验证错误的步骤的输出并稍后在我的错误消息中引用这些输出。 有没有其他方法可以解决这个问题?
这是我的工作流管道的摘录:
jobs:
pre-commit:
steps:
- name: Check for changed files
id: file_changes
uses: trilom/file-changes-action@v1.2.3
with:
output: ' '
- name: Set up pre-commit cache
id: commit_check
uses: pre-commit/action@v2.0.0
with:
extra_args: --files ${{steps.file_changes.outputs.files}}
- name: PR comment
if: failure()
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ' Ups, something went wrong. Please checkout the following error: '
});
【问题讨论】:
-
为什么需要评论?失败的工作还不够吗(而且用户无论如何都会点击它?)
-
我想应该够了。谢谢你的回答。
标签: github-actions pre-commit pre-commit.com