Python webserver that listens for webhooks on a reposity and then does a pull to get latest code
forked from http://logsol.github.io/Github-Auto-Deploy/
Requires linux, apache
- python
- git
sudo apt-get install python git
Get a copy of this repo, store in "/opt". We can't keep this in the home dir because that is encrypted and doesn't stay running after logging out
cd /opt
git clone https://github.com/USGS-WiM/Github-Auto-Deploy.git
This command starts and keeps the service running as a background service
/usr/bin/nohup python /opt/Github-Auto-Deploy/GitAutoDeploy.py > /dev/null 2>&1 &
This command will get a copy of the repository that will be the base for the deployment. Run this from your home folder, ie "/home/ubuntu"
cd /home/ubuntu
git clone https://github.com/USGS-WiM/StreamStats.git
This creates a symbolic link between the github repository in your home folder and the apache web server home folder. Here we can specify to only make the symbolic link from a specific folder in the github reposity, ie "/dist" in the example below.
ln -s /home/ubuntu/streamstats/dist /var/www/html/streamstats
Edit the file "/opt/Github-Auto-Deploy/GitAutoDeploy.conf.json"
sudo nano /opt/Github-Auto-Deploy/GitAutoDeploy.conf.json
add an object like:
{
"url": "https://github.com/USGS-WiM/NSS",
"path": "/home/ubuntu/NSS",
"deploy": "echo deploying"
}
On the Github page go to a repository, then go to "Settings" on the right, then "Webhooks & Services", "Add webhook" under "Webhooks." Add the url of your machine + port (e.g. http://example.com:8001). Specify Content type as application/json. Leave the event as just the push event.