【问题标题】:Retrieve the output error from a github actions step从 github 操作步骤中检索输出错误
【发布时间】: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


【解决方案1】:

无法使用提供的操作。除非有某种命令行参数,否则您可以传递给 pre-commit 以将错误写入文件,然后将其传递。我浏览了文档,但没有找到。

如果你真的需要这个,你将不得不编写你自己的动作。

【讨论】:

    猜你喜欢
    • 2023-02-07
    • 2020-12-15
    • 1970-01-01
    • 2019-08-02
    • 2020-12-07
    • 2020-06-08
    • 1970-01-01
    • 2020-01-11
    • 2023-04-03
    相关资源
    最近更新 更多