github-actionsgithub-apioctokit-jsgithub-check-run

Add check to a specific workflow-run/check-suite using octokit


I have a project with Github Actions that implements multiple workflows that can be triggered by a single push event (depending on path filter).

So a push with a single commit can trigger multiple workflows, so far so good.

In each workflow I am running actions/github-script to create dynamic run-checks with the following step:

- uses: actions/github-script@v4
  with:
    github-token: ${{ inputs.github-token }}
    script: |
      const date = new Date();
      const check = await github.checks.create({
        owner: "${{ steps.vars.outputs.owner }}",
        repo: "${{ steps.vars.outputs.repo }}",
        name: "Custom Script",
        started_at: date.toISOString(),
        completed_at: date.toISOString(),
        head_sha: "${{ inputs.sha }}",
        external_id: "${{ github.run_id }}",
        status: "completed",
        conclusion: "success",
        output: {
          title: "Some funny title",
          summary: "Build successful",
          text: "Image pushed to https://${{ inputs.region }}.console.aws.amazon.com/ecr/repositories/private/${{ inputs.customer-id }}/modix/base/${{ inputs.image }}"
        }
      });

It is working like a charm, when a single workflow is triggered, but as soon as a push triggers multiple workflows, then only the first one that runs is showing the added check. all others but the first don't show the check but also no error?

Before I have tried the LouisBrunner/checks-action and it had the same problem so I created an issue: https://github.com/LouisBrunner/checks-action/issues/26. But now that it also fails by directly using octokit with github-script action, it feels like the problem is somewhere else...

UPDATE:

According to Gregors answer, I have tried giving the check a different name in each workflow by appending the run-id, I found that each parallel workflow is adding the check to the workflow that runs first... so the question now is, how to send it to a specific workflow run?

according to these docs, there is no dedicated parameter for that, it seems that it automatically detects the workflow using the head_sha?

name: "Custom Script ${{ github.run_id }}",

enter image description here


Solution

  • Sadly I found that it is simply impossible to attach a check to a specific workflow-run or check-suite. The problem is known for over a year now, but they didn't provide any solution yet. See in this thread.

    In the name of a big automotive company, I have now submitted a feature request in the official feedback form of github.

    PS: If the feature will be implemented in the future, I am going to create and accept another answer here.