Necessity is the mother of invention. And Frank Zappa is the father.
One of our clients has a Windows web server at Rackspace behind a VPN as their test environment. Every time the client asked for an image to be moved 5px to the right, my designer would push to GitLab, and I would have to establish VPN, remote into the web server, and do a pull in the local repo in IIS. A time consuming, and given the number of client requests, maddening process.
So I thought, it would be great to just push to IIS from our local repositories. Here’s how to do it.
- Install Git and the bash tools for Windows
- Install the Bonobo prerequisites, if necessary. Note: Bonobo requires .NET 4.5
- Install Bonobo
- Allow the IIS user to modify your deployment folder in IIS, just like you did for the App_Data folder in the Bonobo install
- Create a new repo in Bonobo. I’ll call it “myrepo”.
- Navigate to the myrepo’s Details page and note the URL. It will likely be http://localhost/Bonobo.Git.Server/myrepo.git
- Set the remote in your local repo to the one you just created. You’ll want to switch out localhost for the IP of your server.
- Back on the web server, navigate to the hooks folder in your repo using Git Bash. Found at: C:\inetpub\wwwroot\Bonobo.Git.Server\App_Data\Repositories\myrepo\hooks
- In Git Bash, enter “touch post-receive” and then “chmod +x post-receive”
- Open post-receive and add the following text. I usually just do this in a text editor like Notepad++.
echo -e "[log] Received push request at $( date +%F)" >> $LOGFILE echo "[log] Starting Deploy..." >> $LOGFILE GIT_WORK_TREE="$DEPLOYDIR" git checkout -f echo "[log] Finished Deploy" >> $LOGFILE
11. The DEPLOYDIR variable should be the path (formatted like above) to your deployment folder from step 4. This script will also create a handy log file in your repository folder
12. Push some changes from your local repo, and you should you see them out on your site