【问题标题】:Custom "details" link in the github pr checksgithub pr 检查中的自定义“详细信息”链接
【发布时间】:2022-07-28 01:06:48
【问题描述】:

我看到 Chromatic 动作能够更改 PR 检查中的“详细信息”链接并发表附加评论。 有人可以帮我在自己的工作流程中进行设置吗? check the image for example

【问题讨论】:

    标签: continuous-integration github-actions cd chromatic


    【解决方案1】:

    似乎 GitHub Actions:checks-action 是解决您问题的好方法:

    jobs:
      test_something:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v1
        - uses: actions/create-outputs@v0.0.0-fake
          id: test
        - uses: LouisBrunner/checks-action@v1.1.1
          if: always()
          with:
            token: ${{ secrets.GITHUB_TOKEN }}
            name: Test XYZ
            conclusion: ${{ job.status }}
            output: |
              {"summary":${{ steps.test.outputs.summary }}}
    

    output 字段可能会有所帮助:

    output:
    Supports the following properties:
    
    summary: Required, summary of your check
    text_description: Optional, a text description of your annotation (if any)
    

    链接到Marketplace

    【讨论】:

    • 这是我需要的。谢谢!
    【解决方案2】:

    我相信它们来自外部来源,而不是 GitHub Actions。 如果您使用的是 GitHub Actions,我认为这是不可行的。

    但是,您可以创建一个部署环境并将url 参数添加到其中,以便您可以单击"View Deployment" button

    https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment

    【讨论】:

      【解决方案3】:

      您可以使用 GitHub REST API 为您的 PR 创建自定义检查。特别是,您想查看Checks - Create a check run。该端点的部分负载是一个名为 details_url 的字段,您可以在其中指定 URL。

      使用 curl 的示例 API 调用:

      curl \
        -X POST \
        -H "Accept: application/vnd.github.v3+json" \
        https://api.github.com/repos/octocat/hello-world/check-runs \
        -d '{"name":"name","head_sha":"head_sha", "details_url": "https://my-custom-url.com"}'
      

      【讨论】:

        猜你喜欢
        • 2023-04-09
        • 1970-01-01
        • 2012-05-23
        • 1970-01-01
        • 1970-01-01
        • 2020-04-15
        • 2015-12-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多