In previous posts I described my setup with Netlify for automatic deployment and even how to receive push notifications when a deployment succeeds. Today I bring you an alternative to automatic deployments, doing it manually from your iPhone with Shortcuts and Siri.
In this post I'm gonna describe how to set up your Shortcut using the Shortcuts App available for iOS 12. The same process should work fine with the Workflow app in previous operative systems.
First we need to get the unique URL that Netlify uses to trigger a deployment.
For that just go to your Deployment settings and you will find the Build hooks section. Create a new build hook give it the name you want and select the branch that you want to deploy, usually master.
As an aside, being able to select the branch to deploy opens a world of possibilities. You can easily have an staging environment to preview your drafts easily. This can also be automated so every branch is automatically deployed, for this, an more useful features that Netlify offers, you can read the previous post.
After the hook created you can copy the URL and even test that it works by running the curl command offered in your terminal.
The shortcut in iOS is really simple to create. Just go to the Shortcuts app and start a new one.
You will need 2 actions for this to work:
- Get Contents of URL
First you need to paste the URL from Netlify in the field of the first action. Simple as that.
A nice tip here: If you have iCloud Pasteboard enabled you can just copy the URL in your Mac and paste it in iOS. 🎉
The second action is also really easy to setup. Just open the Advanced options and change the Method to POST.
That's it! You can now run the action and Netlify will start the deployment! And if you have notifications for deployments configured you will receive it some seconds after.
I have this setup as a Today Widget so it's easy to access but you can show it whenever is better for you, maybe your dream has always been to deploy from your Apple Watch, well, now you can!
Deploy using Siri
With iOS 12 you can trigger any Shortcut using your voice thanks to Siri. To add the deployment shortcut to Siri go to Settings/Siry & Sarch/More Shortcuts.
In there you will find some available shortcuts to add, look for yours, record a message and that's it.
Now Siri can deploy your website!