We have been using Azure repos to manage our server files. We have created a simple python script that syncs files with remote repository. I thought this might be useful for someone so I am just going to share it. Note that this is for developers with basic knowledge in git and python. If you aren’t, you can always ask ChatGPT about it or research online.
Why you should use git
Using git is crucial when it comes to developing any kinds of servers. I still see lots of people using remote desktop and directly edit the files and just make dumb mistakes like deleting important files without any backups. Git helps you prevent from happening that kind of things. Also, if you want to closely monitor what your developers are doing, using git is useful because you can check every single commit history.
Requirements
Python
Python needs to be installed on your production server.
ngrok (optional)
ngrok is useful for exposing the web application to the internet.
gitautopull-flask.py
Download the python script from this repo.
How to use it
We are using Azure repos because FiveM server is typically around 30GB, and other git host service (github, gitlab, etc) does not allow us to push large files. Azure repos allow us to store up to 200GB.
1. Install python
Install python. Make sure to create a PATH. There are tons of resources on how to do it online.
Also, if you are not familiar with forwarding or dynamic / static IP, you might want to use ngrok.
2. Install Flask
Flask is a light weight web application framework for python. If you have installed python correctly, you can type this in to command prompt and it should do the job for you.
pip install flask
3. Create a git repo
Create a git remote repository and push the files. Make sure to initialize and git remote add origin
correctly. I am going to create a in-depth guide if you guys want.
4. Edit gitautopull-flask.py
In the python code that I created, you can add 3 different local folders to sync. You have to edit at least 1 your_local_repo_directory
part in order for this to work. Also, by default, this application uses port 999 to rescieve post request. If you have already using it, change it as you like.
if __name__ == '__main__':
app.run(host='0.0.0.0', port=999)
5. Run the application and recieve api requests
you can run the application by python gitautopull-flask.py
. If you have correctly portforwarded port 999, you can just test this application by creating post requests to http://your_server_ip:999
.
Additionally, if you want to use ngrok for better security and simplicity, you can open ngrok.exe
and type in ngrok.exe http 999
. You can set it accessible for everyone or if you choose to add more security features you can set username and password.
6. Register your webhook address to git services.
There are different ways to do that depeding on the services you use. Here are the common ones: