Here at bluz, we use DeployBot to build and deploy all our docs, websites, web apps like the Gateway Console, and everything else. It is a great little tool, but we just hate having to actually sign in to build and deploy our code! Our staging and testing servers build and deploy automatically whenever we checking, but having to go to the website and dig through all the listings to deploy to production seems so.... effortful (that, or we're just lazy!)
So, we built ourselves a little portable remote that we can deploy our code with the power of the IoT. We wanted a screen and a way to toggle through our builds, so we used the Modulo platform with their fantastic set of modular components. They have a base built specifically for the Particle platform which works perfect with bluz since it is pin-compatible. This means the remote is built completely without soldering or breadboarding, just snap the pieces together!
First, we setup the knob to scroll through the builds that we want to deploy. When we get to the one we want, a simple click brings up the confirmation screen (hey, don't deploy production code without double checking first!). One more click and the build kicks off.
Using Webhooks and Particle.publish events, we can send REST calls directly to DeployBot. They have a great API that we can kick off a build and then poll the results to get the status. If the build succeeds or fails, the remote will tell us by displaying the message on the screen. Instant feedback!
Here is the remote in progress:
With the bluz firmware, you can pretty easily customize which builds you want to deploy, just change the array which changes the list displayed on the screen. Or use the remote for any other task you want to automate (turn on lights, control your thermostat, launch Skynet, whatever!)
We use two Webhooks to DeployBot, the first is to kick off the build and the second is to poll for the status. In each case, we use the response template to format the results so we only get back the data we need. The response template lets you break apart the json response from the API and hand down only the parts you need to bluz.
For the Build Webhook, we hand back only the id of the new build and ignore all other data so we don't have to parse json responses on the microcontroller, which is much harder (and remember, we're lazy!). With that id, we send a new Webhook to get the status of the build and use the response template to hand us back only the state. We then poll that until the state hits one of the three final options: failed, skipped, or success.
Now we can just sit back and deploy our builds wherever, whenever (and most importantly, be lazy!)
Comments