Skip to content

A web API that uses the supplied repo, label, style and icon to generate a badge image.

License

Notifications You must be signed in to change notification settings

realdegrees/unity-badges

Repository files navigation

Unity Badges

Description

A REST API that returns an image containing a badge that can be used on GitHub to display specific stats about a Unity project. I made this as a side project to improve the collaborative aspect in a Unity project repo for a game engineering course at my Uni.

It's a Flask API that uses the route and arguments to create a badge as a png file that can be embedded into e.g. READMEs in github. The badges are created by taking the data that was queried using the repo defined in the route and applying it to a Jinja template. The resulting html is rendered using a headless browser by Playwright. A cropped screenshot of the page shows the final badge which is then returned in the response.

Basic Caching using Flask-Caching and redis and a rate limiter using Flask-Limiter are included. If unable to connect to redis the app defaults to in-memory caching. Launching the app with start.sh uses gunicorn to run 4 worker processes running the app.


Here is a live example of the scene-changes badge using the unitystation repo as an example:

Unity Badge

Requirements

Playwright Setup

While playwright is part of the requirements it needs to install dependencies and the chromium browser before launching the app. This is automated in the Dockerfile and packages if deploying with docker.
playwright install-deps
playwright install chromium

Endpoints

Type Route Generic Url Args (Can be used for all badges)
GET /<badge>/<owner>/<repo> label

Badges

Badge Description Custom Url Args
scene-changes Checks the diffs between feature branches
and a base branch (base argument (Default: develop)) for .unity files.
The modified Unity scene files are listed in the badge.
Possible conflicts between the scenes are highlighted.
base

About

A web API that uses the supplied repo, label, style and icon to generate a badge image.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages