toolkit: Unable to create annotations

I have two actions that create annotations after running eslint & stylelint but I have yet to move them to v2. They run fine in v2 workflows though and annotations are created as you’d expect.

I’m trying to setup a new action that creates annotations just like my other actions but using the toolkit packages. I’m able to create a checks run using GITHUB_TOKEN and the github client, but I’m not able to call the update checks function with the annotations. I keep getting a 422 response back. Are there differences between v1 and v2 actions that would prevent this from working?

This call works:

const githubClient = new github.GitHub(core.getInput("repo-token", { required: true }));

const { data } = await githubClient.checks.create({
  ...github.context.repo,
  name: github.context.action,
  head_sha: github.context.sha,
  started_at: new Date().toISOString(),
});

But this call doesn’t:

const githubClient = new github.GitHub(core.getInput("repo-token", { required: true }));

const { data} = await githubClient.checks.update({
  ...github.context.repo,
  check_run_id: id, // data.id from the first call
  completed_at: new Date().toISOString(),
  conclusion: conclusion,
  output,
  status: "completed",
});

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@thboop I switched one of my JS actions over to use a problem matcher. It’d be helpful if there was a function in the toolkit to facilitate registering them (they seem to still use ## instead of :: based on the setup environment actions). The lines in the log are being highlighted as errors, but annotations aren’t created. Is that part functional yet?

@thboop I forgot to ask, when creating annotations with the api you can add action buttons to them. The UI shows them and reacts to clicking them, but I wasn’t able to get that to trigger a workflow on check_run:requested_action. Is this something that’s possible with actions right now?

@xt0rted , that doesn’t seem intended. Other users recently reported similar issues with triggering workflows from apps. I’ll pass along that you are seeing this issue as well to our engineering team. You can also reply in the community forums.

Just for clarity’s sake, I do not think that issue is related to the toolkit.

Hey @xt0rted The checks API requires the head_sha, the sha provided by github.context.sha for pull_request builds is a merge sha, so these do not end up aligning.

I’m going to take this feedback to the team and see how we can improve this experience! Thanks for your feedback and quick responses on this item we really appreciate it!

For now, you can use access the head_sha for pull request builds via github.context.payload.pull_request.head.sha. I’ve confirmed that I can see the annotations for those builds.

I will also file an item for the 422 response code you were seeing and see how we can improve that messaging and error handling.

@xt0rted Sounds great, thank you! I can confirm I can push annotations as well, I’ve updated the above code snippets.

@thboop I’ll have to take a look at this again later, but the main difference I see between the two setups is yours isn’t creating annotations in the update call. I’m able to create the checks run just fine, but when it comes to the annotations that’s when the request fails.