jongracecox / anybadge

A Python project for generating badges for your projects, with a focus on simplicity and flexibility.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

host the svg created by anybadge

yangzhang21 opened this issue · comments

commented

is there anyway to host and update the svg badge file created by anybadge dynamically on github so we can embed it on README? I couldn't figure out a working solution.. need some guidance. thanks!

I'm not sure if/how that can be done on GitHub. I do know it can be done on GitLab because GitLab allows CI pipeline artifacts to be stored and accessed. I quickly read through the GitHub documentation on workflow artifacts: https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts

There is a note in the middle that states:

Note: You can only download artifacts in a workflow that were uploaded during the same workflow run.

This says to me that, even if you could create a badge as an artifact, you won't be able to access it outside the workflow.

Here's some more documentation: https://github.com/actions/upload-artifact

During a workflow run, files are uploaded and downloaded individually using the upload-artifact and download-artifact actions. However, when a workflow run finishes and an artifact is downloaded from either the UI or through the download api, a zip is dynamically created with all the file contents that were uploaded. There is currently no way to download artifacts after a workflow run finishes in a format other than a zip or to download artifact contents individually. One of the consequences of this limitation is that if a zip is uploaded during a workflow run and then downloaded from the UI, there will be a double zip created.

An alternative might be to upload it somewhere and reference that location. I found this: https://github.com/evertdespiegeleer/github-image-upload, which is a way to make use of GitHubs CDN that is used for this commenting system. When you drag and drop a file into a comment it get's uploaded to the CDN and made available. I think you can use this package (or maybe a similar one) to upload a file and use that as your image location. The down-side to this approach is that the image path will change each time, so you would need to edit the README.md path, which kinda defeats the purpose.

Sorry to not be of more help. Maybe others can help. I'm also interested.

I know this doesn't directly answer your question, but here's a post I wrote on how to do this on GitLab: https://stackoverflow.com/a/47343010/6252525

commented

Thank you @jongracecox , I spent quite a time on this but couldn't figure out a good solution. Maybe this is a feature request for Githut :)

@yangzhang21, are you OK if I close this issue? I'm not sure it's within the scope of the python package. If I find an easy / obvious way to do it in future I'll update the docs, but for now I can't think of anything.

commented

@jongracecox sure, please close it. thanks