I want to store the configuration of a no-code tool, as a JSON file, into a Git repo. (GitHub)
I'd get this "config" object (JSON), which contains the configuration of all my database tables and columns, and I want to push it into a Git repository at a regular interval (whenever there are changes).
The goal is to keep track of that file across time, to see what has changed and when, as well as having a backup of the DB structure.
Getting the data is not the issue, I'm more interested about how Git could help. I'm concerned about automatically committing/pushing that file at a regular interval (I don't know what issues I might run into).
Also, and that's probably the hardest part, I want to generate files based on the "config" object. Basically re-creating the whole database structure using folders and files, so that all "columns" of the db have their own text file that describes their configuration.
So, at a regular interval, I'd need to:
- Get the newest version of the config file (using JS)
- Commit the config file (I'm not sure how to do this automatically, I've only ever used git manually, not programmatically, I guess I need to use something like https://github.com/nodegit/nodegit)
- Generate new files (or update existing ones) based on what's changed (I'm thinking on using GitHub Actions to generate the files and commit/push them after the config file has changed)
I wonder if Git conflicts could arise and how to avoid them, thinking of pushing in force mode all the time to avoid that, not sure if it's a great idea either.
Here is an example of the "config" I mentioned: https://gist.github.com/Vadorequest/6972b9cc91b36e4273bd80eaa28a84cd
I wonder if I could use something like Vercel to host the API that would commit the config file to my git repository, or if I can do that from a browser directly (committing from a Chrome Extension, probably not secure though, hence the need for an API).
I guess I could then simply react on "changes" in the GitHub repository to trigger a GitHub Action that would detect which file should be re-generated, generate them and commit/push them onto the repository.
One of my main concerns with this design is about to Git conflicts, if I keep making programmatic commits/pushes from different sources, I'll probably run into conflicts, and I'm not sure how to solve those programmatically.