How do I produce a status that can be displayed via the badge from a github action?

Viewed 792

I've defined a github action and it runs successfully on every push and every pull request, completing with a green check mark when tests pass.

However it never produces a status, or at any rate the github status badge always says "no status."

In addition, I am unable to choose this action as a precondition for merging pull requests because it has no status and so cannot be chosen via the "Require status checks to pass before merging" selector.

Am I trying to do something that just can't be done without explicitly emitting a status via the github API, or is there a more straightforward way to attach a github action as a precondition to a PR merging?

The github action is here: https://github.com/apostrophecms/apostrophe/blob/main/.github/workflows/main.yml

And I'm using this markup for the badge:

![Unit Tests](https://github.com/github/docs/actions/workflows/main.yml/badge.svg)

(This is an open source repository, so everything is available for inspection.)

1 Answers

It looks like you've added a badge with the example URL instead of customising it with your username and repo:

![Unit Tests](https://github.com/github/docs/actions/workflows/main.yml/badge.svg)

(It's weird it picked up the name of the action correctly.)

You need to replace that URL with

https://github.com/apostrophecms/apostrophe/actions/workflows/main.yml/badge.svg

(Where by "you need" I mean "I sent you this PR".)

Related