page icon

Embedding Pixela graphs in GitHub

README or profile in GitHub repository might be a good place to embed Pixela graphs.
 
For example, let’s record the number of CI workflows executed in your repository to Pixela and embed the graph in the README. It will let people know how actively the repository is being developed.
In Pixela’s GitHub repository, we place alert indexes for Pixela service availability as a Pixela graph.
In Pixela’s GitHub repository, we place alert indexes for Pixela service availability as a Pixela graph.
 
GitHub supports Markdown format. So, whether it is READMEs or issues, you may embed your by writing the following:
![](https://pixe.la/v1/users/<username>/graphs/<graphID>)
Markdown
 
However, there is one thing that you need to be careful of. That is, GitHub automatically caches assets such as images.
If you place an image in Markdown as shown above, the URL for that image will probably be something like this:
https://camo.githubusercontent.com/00af1563280f78def22af3a6614/68747470733a2f2f706978652e6c612f76312f75736572732f70697cf78b2a9f69a288f8949643d81dbcae203ea0865696e646578c612f6772617068732f616c6572742d6
Markdown
This means that even if you update Pixela graphs, the cached images of the graphs on GitHub will still be displayed. It is not possible to always display the latest information.
 
GitHub already provides a way to clear the caches. You can expire the caches by requesting it with GitHub’s custom HTTP method, PURGE , as follows:
 
$ curl -X PURGE https://camo.githubusercontent.com/00af1563280f78def22af3a6614/68747470733a2f2f706978652e6c612f76312f75736572732f70697cf78b2a9f69a288f8949643d81dbcae203ea0865696e646578c612f6772617068732f616c6572742d6
{ "status": "ok", "id": "99999-0000000000-11111" }%
Shell
 
And Pixela also supports this way. Only if you set the URLs that you want to PURGE to purge_cache_urls of the graph, you achieve that PURGE requesting to the GitHub cache every time the graph is updated.
 
The purge_cache_urls of the graphs should be set as follows, for example:
$ curl -X PUT https://pixe.la/v1/users/<username>/graphs/<graphID> -H 'X-USER-TOKEN:thisissecret' -d '{"purgeCacheURLs":["https://camo.githubusercontent.com/xxx/xxxx"]}'
Shell
 
Now you can embed your graphs in GitHub without worrying about whether the images of the graphs are cached by GitHub, right?

Notes

Even if the Pixela graph that you will embed is the same, embedding the graph in different places in GitHub will generate each different URLs ( https://camo.githubusercontent.com/xxx/xxxx ).
Therefore, Pixela supports that specifying up to 5 GitHub cache URLs in purgeCacheURLs property.

Related