I have been using Git deploy for the past year. But my simple hack is to use the hook that is available in Github or Gitlab. That will trigger a script in the designated server and does a git pull.
Another step is this — it doesn’t simple pull everytime there is a push from the developer. It will only do a pull when it is of specific branch, ie “live”. Also not everybody can actually push to this branch. So before anything is merge to the “live” branch, it is thoroughly tested on staging, dev, etc.
But then comes the problem of autoscaling. I am on AWS, I user their ELB load balancer and I have created an autoscaling rule where servers (EC2 instance) will be added and remove based on certain rules I’ve set, like CPU usage percentage, etc. The problem with this setup is that I can’t simply create a new hook every time a new server is added — especially when I don’t quite know when that is.
So I created a PHP script (let’s call it githook.php) to handle this for setup at AWS with Autoscaling. githook.php is triggered from GitLab’s hook settings. It queries your load balancer and asks for information of the instances under it. And then it will trigger a web requested to specific URL (let’s call this gitpull.php) using the instances’ IP address. gitpull.php will simply do a git pull for the project.
And today, I just discovered AWS has CodeDeploy…
Any, if anybody finds this useful. https://github.com/kidino/Git-Deploy-ELB
I have been using Git deploy for the past year. But my simple hack is to use the hook that is available in Github or Gitlab. That will trigger a script in the designated server and does a git pull.
Another step is this — it doesn’t simple pull everytime there is a push from the developer. It will only do a pull when it is of specific branch, ie “live”. Also not everybody can actually push to this branch. So before anything is merge to the “live” branch, it is thoroughly tested on staging, dev, etc.
But then comes the problem of autoscaling. I am on AWS, I user their ELB load balancer and I have created an autoscaling rule where servers (EC2 instance) will be added and remove based on certain rules I’ve set, like CPU usage percentage, etc. The problem with this setup is that I can’t simply create a new hook every time a new server is added — especially when I don’t quite know when that is.
So I created a PHP script (let’s call it githook.php) to handle this for setup at AWS with Autoscaling. githook.php is triggered from GitLab’s hook settings. It queries your load balancer and asks for information of the instances under it. And then it will trigger a web requested to specific URL (let’s call this gitpull.php) using the instances’ IP address. gitpull.php will simply do a git pull for the project.
And today, I just discovered AWS has CodeDeploy…
Any, if anybody finds this useful. https://github.com/kidino/Git-Deploy-ELB