This is a simple git auto deployment script. when you push your commits to your repository, this service automatically pulls commits and deploys your project on your server.
Clone this project on your Linux server and open its dir
git clone https://github.com/amirhnir/SimpleGitAutoDeploy.git
cd SimpleGitAutoDeploy/
Look at the example.config.json and according to this, edit the config.json file as you need.
cat example.config.json
vi config.json
To run this script permanently, you need to create a Lunix service
sudo vi /etc/systemd/system/simple-git-auto-deploy.service
This command creates a new service and you have to write some lines inside the file to specify what this service will do.
[Unit]
Description= Simple Git Auto Deploy
After=syslog.target
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/python /path/SimpleGitAutoDeploy.py
TimeoutSec=300
[Install]
WantedBy=multi-user.target
in the above code, you have to edit /path/SimpleGitAutoDeploy.py to the real path of SimpleGitAutoDeploy.py file. also User and Group are set to root but it's better if you change these parameters to a normal user/group.
sudo systemctl start simple-git-auto-deploy
sudo systemctl enable simple-git-auto-deploy
You must set a webhook in your git repository then when you push anything in your repository, your repository sends a post request to your server and the SimpleGitAutoDeploy handles the rest.
- Go to your repository -> Settings -> Webhooks -> Add webhook
- In "Payload URL", enter your hostname and port (default port:8075)
- Click "Add webhook"
Note: SimpleGitAutoDeploy only supports GitHub for now.