1

The GitHub API documentation shows an example for retrieving repository workflows.

The response includes a badge_url field for each workflow. For example:

"badge_url": "https://github.com/octo-org/octo-repo/workflows/CI/badge.svg"

Is it possible to retrieve the badge using the GitHub API? My question arises for a scenario where I'm trying to retrieve the badge for a private repository, and it would be more convenient to use the GitHub API versus alternative approaches.

dannyadam
  • 3,950
  • 2
  • 22
  • 19
  • Can you please show what you have tried and how that does not solve your use-case? What do you mean with "more convenient"? In any case, if you're looking for something like `api.github.com....` I doubt that exists. – rethab Aug 09 '22 at 05:18
  • The request is made from a web page. I've tried accessing the URL directly, using an `` element with `crossorigin="use-credentials"`, but this doesn't work since GitHub doesn't provide an `Access-Control-Allow-Origin` response header. By "more convenient", I was thinking there could be alternative approaches like a server-side request, but this webapp runs fully in the browser (no server calls). I was looking for something that uses `api.github.com`. I know the API can be used to request files (e.g., repository files, workflow artifacts), so I thought badges may be available some way too. – dannyadam Aug 09 '22 at 16:04

0 Answers0