Through the magic of simple bash scripting, I now have a very easy deployment pipeline for my website. I wanted to do this all in Visual Studio Team Services, but as far as I can tell, I’ll need to register a custom Linux deployment agent (aka a Linux VM running somewhere).

Since I don’t want to do that, I used the Windows Subsystem for Linux, bash scripting, and the Netlify API to automate my deploys. This is how it works.

I write my blog post in my text editor. I save it, and push the commit to VSTS - this is mostly just for backup, since the deploy is all happening on my machine. After pushing to VSTS, I run this simple script in WSL:

!#/bin/bash
jekyll build -s $PATH_TO_SITE/AdityaNag.com > /dev/null 2>&1 
zip -r site.zip _site > /dev/null 2>&1
curl -H "Content-Type: application/zip" -H "Authorization: Bearer <OAUTH_ID>"--data-binary "@site.zip" https://api.netlify.com/api/v1/sites/adityanag.netlify.com/deploys > /dev/null 2>&1

This generates the site, zips it up, and deploys it to Netlify. The entire process takes between 25-40 seconds (my site isn’t very big). I could shrink that further by doing incremental builds or something, but I’m ok with this for now.

Finally, I use the email notification feature in Netlify to notify me when the build is sucessfully deployed.

I wish VSTS would provide a Linux agent that has Jekyll built in. I suppose I could always switch to Hugo, but that’s a bigger project - maybe a weekend project!