Interacting with GitHub in Processing

I am making a project that I occasionally want to push and pull from a GitHub repository, this is cause I have a level editor, and I want it to be possible for people to upload their levels so others in other places can find and play them,I was wondering if there was a way to push to a repo.

1 Like

Do you want the sketch to have a button in it that submits a level to a repo?

Github has an API (with several third-party Java API tools), so this is possible by adding a Java github library to a processing sketch and using it to fork, commit, and pull requests:

– but the user would need to enter their github username and password in order to push anything. You would want them to fork a shallow copy and submit a pull request (because every single user of the game can’t have write access to your repo). You could even add GitHub Actions to automatically process the pull requests. Of course, that’s a pretty huge attack vector – you are now giving people arbitrary, automatic write permission that is then synced to the computers of all your users and executed. Bad!

So, possible, but github isn’t designed to host crowdsourced data in this way – it doesn’t make sense to ask many players to create github accounts just so they can fork the level editor data. You would probably do better having a simple server for them to send the data to, and then a bot / script on the server that commits to github.

In general, the best thing is to treat user data as data, not files. To minimize problems (attacks, bugs, and user error) you probably want to parse submissions on the server side, then generate new, valid, safe levels to distribute based on the valid submissions that you parsed.

1 Like