One of the artifacts that my build produces is a badge in SVG format.
I would like to show this badge in my GitHub readme.
I can access the file by using the following API call:
Artifacts in CircleCI are stored for up to 30 days only, so I am wondering if storing your SVG files as artifacts on CircleCI to be used on a GitHub README may be the best approach here.
If this restriction is still workable for you, you may notice that even after obtaining the artifact URL from CircleCI (e.g., https://12-123456789-gh.circle-artifacts.com/0/Users/circleci/project/artifacts/Coverage/Report/badge_combined.svg), this URL is essentially a HTTP 302 “redirect” to the actual file stored in S3. If this is a private project as well, you’d need to be logged in to CircleCI with sufficient permissions to get the actual URL from the Location header from the response too then.
As such, as an alternative, I wonder if you can make use of secret gists in GitHub to (1) host your SVG file, and (2) make use of the nature of how secret gists are accessible only if one knows the URL
For example, you can use the update Gist API to update your SVG file in the gist. I believe that since the SVG file’s URL on your gist remains the same (just the contents updated over time), your GitHub README should be able to reference it and display it as an image via Markdown.
@kelvintaywl thanks for the reply.
This is what I ended up doing. When the main branch builds successfully, I update the badge images in my Gist and reference the badges from there in the readme. It works like a charm.
@gpetrounrt glad to hear that’s the approach you took too!
I’d like to think it’s a pretty sweet setup, given that it’s simple to set up and maintain!
I’m happy to hear that your issue is resolved then