Embedding commit history on pages

I host a page on GitHub pages and wanted to embed a changelog on the page that would be pulled from the repo commit history. I wasn’t sure if I could use the GitHub API through GitHub pages, so figured out a possible hacky way was to request the HTML of the commit page through $.get() and to go through it, parsing it and filtering out the information I need. This worked fine until I pushed it to GitHub - I get the following error:

Access to XMLHttpRequest at ‘https://github.com/Bassoonian/bassoonian.github.io/commits/master’ from origin ‘https://bassoonian.github.io’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Is there some other way to gain access to the commit history of a given repository, either through the API or through some other means, and to display it on GitHub Pages? Thank you in advance!

You should be able to, as long as you do it in a script on the web site itself. However, there’s pretty strict rate limiting for unauthenticated requests.

An alternative might be to use Actions to statically build your changelog page from the commit history. Use actions/checkout with fetch-depth: 0, parse whatever you need from the repository and generate the page, and then commit & push.

1 Like