从 github 操作步骤中检索输出错误

Retrieve the output error from a github actions step

我正在尝试构建一个 GitHub 工作流,它会在某个存储库中创建 PR 时执行简单的提交前检查,并在某些检查失败时触发消息。 问题是我希望该消息尽可能具体,因此,该消息必须包含阻止检查成功的错误。 为了执行预提交检查,我使用 pre-commit action and, to automate the messages, I am using the official actions github-script.

由于我正在利用 预提交操作 来执行检查,我认为我无法使用 解决方案来定义验证错误并稍后在我的错误消息中引用这些输出的步骤。 有没有其他方法可以解决这个问题?

这是我的工作流管道的摘录:

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:  '
            });

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

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