Getting the status of a badge from a private repository
Asked Answered
L

2

16

I’m trying to get the status of a badge in a private repository (the svg image), I’m doing this from an unauthenticated location and I’m receiving the expected 404 error message.

Does anyone know how should I add the access_token information to the GET method to actually be able to get its status?

Calling the badge from URL like:

https://github.com/xx/yy/workflows/zz/badge.svg?event=push&access_token=hhhh

Returns 404.

Also, setting the token in the request's header:

headers: {'Authorization': 'token hhhh', ... }

Returns 404.

Thanks!

Lynch answered 4/6, 2020 at 8:43 Comment(3)
Have you found a solution?Freeliving
Actually the badge is something that is done for readme. It will be the URL that is placed as hyperlink in readme file. I am not sure what you are trying to achieve, but you can place the badge from the public url. I once did the badge to be created and saved to the azure blob storage and accessing it from the azure blob storage and placing the public url to the readme file. I hope this helps.Turbinate
I guess you are showing the badge from something like the readme? It’s not possible to generate a temporary token from there. More context would help for us.Dato
B
3

I assume you're referring to the type of badge that github provides out of the box (https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge).

The example URL from there is (https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE>/badge.svg?event=push).

To answer your question: You can't pass an access token in that query - it's simply not supported.

And even if if were possible, you also shouldn't.

It would mean you are storing a plain, unencrypted secret in your code (==repo) and therefore also on all machines you clone it to. Github access tokens cannot be limited to only allow access the status of Github actions, so that would be a big no-no from a security perspective.

Bomarc answered 14/5, 2023 at 10:30 Comment(0)
C
1
  1. Go to your workflow run and select Create status badge
  2. In the upcoming dialog, choose a branch, choose a event and then click Copy status badge markdown.
  3. Paste the copied markdown onto your README.md and you should see your status.

workflow run

Comer answered 5/6, 2023 at 16:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.