SlimJim was born out of a need for a simple auto update script which would update multiple development/test environments every time someone commits to their respective Github repository.
I know there are many deployment/build scripts out there like whiskey_disk, Vlad and Capistrano which can do this if coupled with a CI server like cijoe, Jenkins, etc.
But I found them to be more complicated to setup just for a basic need i.e to simply update a development/test environment using a post-receive hook without any manual user interaction on behalf of the committer besides git push...
Now lets get to it. To configure SlimJim on your server follow these steps:
Setup site and DB
Basic LAMP setup should suffice. Everything you need is in this repo. I'm using a PHP micro-framework called Slim (thus the name!).
Just don't forget to update the first line in deploy.php to point to the path of your SlimJim directory
Run slimjim.sql on your MySql server
For all the projects that you want to auto-update, add the name of the github repo, branch and the physical path on your server to the Projects table
Modify the IPs in the allowed_from key in the settings table to make sure GitHub or any other site can POST to your endpoint.
Install & setup incron
When the site receives a payload from the post-receive hook it will drop a request in the /requests folder. Incron is needed to listen for that event and trigger the deploy script.
root@yourhost:/# apt-get install incron
Add the root user to your allow list
root@yourhost:/# vi /etc/incron.allow
Add this, save and quit:
root
Now watch your requests directory for updates
root@yourhost:/# incrontab -e
Add this, save and quit:
/srv/www/slimjim.yourcompany.com/public_html/requests/ IN_CREATE php /srv/www/slimjim.yourcompany.com/public_html/deploy.php $#
Permissions
Give execute permissions to the deploy script
root@yourhost:/# chmod +x deploy.php
Give permissions to pull from github to the root user (make sure to leave the password empty)
root@yourhost:/# ssh-keygen -t rsa -C "root@yourhost"
Copy and paste the contents from ~/.ssh/id_rsa.pub to Account Settings > SSH Keys > Add SSH key on Github
Add Post-Receive URL
Go to Admin -> Service Hooks and add this URL:
http://slimjim.yourcompany.com/deploy
That's it! Now sit back and watch Jim do the tedious work! :)
Now if you like what this does, feel free to improve upon code. Just follow these steps to contribute:
- Fork SlimJim on GitHub & Clone your fork onto your machine
git clone [email protected]:[YOUR_USERNAME]/SlimJim.git
- Pull the develop branch from the upstream repository
cd SlimJim
git remote add upstream [email protected]:jesalg/SlimJim.git
git fetch upstream
git checkout -b develop origin/develop
- Keep develop up-to-date
git fetch upstream
git rebase upstream/develop develop
- Create a feature branch
git flow feature start my_cool_feature
- Hack Hack Hack
Make sure to commit your work in bite-size chunks, so the commit log remains clear.
-
When ready, push the feature branch to your origin
git push origin my_cool_feature
-
Issue a pull request to my develop branch
-
I will test out your cool feature on develop and do a release to master soon thereafter! :)