Shortcut: Dispatch Bulletin
I’m late to the Shortcuts game.1 I’ve seen others build impressive shortcuts for years but for some reason it took me until late last year to start building some of my own. And really it was my loss, because Shortcuts have long stopped being just a gimmick. They are not a serious tool to mix point-and-click with code to build some serious workflows.
This post is about an iOS Shortcut that I use to publish short posts and photos to my Micro.blog site Bulletin. I call it ‘Dispatch Bulletin’.
Context
Bulletin is built using Jekyll, meaning it’s a static website that needs to be generated each time I make a change, and the generated pages need to be hosted somewhere. Bulletin’s source code lives in a privare GitHub repo, and the site is hosted on Netlify.2
You tell Netlify to watch your site’s repo, and it will automatically build and serve your site whenever it sees a new commit in the branch of choice. It’s really cool.
Dependencies
The Shortcut relies on two third-party apps:
- Scriptable. To run a script that identifies the local timezone and returns its TZ database name.3
- Working Copy. Critical since that’s how the shortcut can add posts and photos to the site’s git repo.
Summary
Brief overview of how it all works. The shortcut…
- Receives text input.
- Detects the local timezone to use later in the post frontmatter.
- Prompts the user for file suffix. i.e., what to add after the date in the post filename.
- Pulls the latest updates to the repo in Working Copy.
- Asks the user if they want to attach a photo.
- If Yes, prompts the user to select the photo from Files.app and generated the body of a photo post. If No, generates a text only post.
- Writes the post and optional image to the repo in Working Copy.
- Commits changes and pushes to remote.
- Displays a notification that the bulletin was published.
Details
Let’s get into it.
step | explanation |
---|---|
![]() |
Accept text input, save value in Bulletin variable. We’ll use that later. |
![]() |
Get current date and time in ISO 8601 format. We’ll use that later. |
![]() |
Run TZIdentifier script. See below for the simple code. We’ll refer to its output later. |
![]() |
Prompt for the file suffix and create a text variable of the full file path. Okay you get it, I won’t keep saying “we’ll use that later”. |
![]() |
Pull any new commits to the local repo in Working Copy. |
![]() |
Ask if I want to attach a photo to the bulletin. |
![]() |
Self explanatory. |
![]() |
Browse Files.app for the photo, save the photo to the proper path in Working Copy and stage it for commit. |
![]() |
Ask for image alt text. |
![]() |
Create the body of the photo bulletin and save it to BulletinBody variable. |
![]() |
If you don’t want to attach a photo… |
![]() |
Create text only bulletin and save it to BulletinBody variable, then end the if statement. |
![]() |
Save BulletinBody to a Markdown file in Working Copy and stage it for commit. |
![]() |
Commit all staged files with a simple commit message and sign the commit with the key Working Copy already has. |
![]() |
Push changes to remote. |
![]() |
Show a fancy notification at the end. |
At this point my work is done and Netlify takes the wheel. Once the shortcut is done pushing the commit, Netlify will detect the commit to the main branch, pull it, build it, then serve it.
Appendix
Here’s the TZIdentifier
script run in Scriptable:
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
function main() {
Script.setShortcutOutput(tz)
}
main()
Final notes
I had a lot of fun building this. It holds the highest honor an automation can receive: I use it all the time. It’s the most convenient way to publish to a Jekyll site I’ve ever worked out and it’s how I publish 9/10 posts to Bulletin.
-
A note on capitalization. “Shortcuts” is a noun but it’s also the name of the app itself. Classic Apple. My executive editorial decision is to capitalize ’Shortcuts’ and not ’shortcut’. ↩︎
-
From what I can tell Netlify is one of the most common ways to host a Jekyll site online besides Github Pages. It’s a really pleasant experience to set up, and they have a free tier that will work for most hobbyists like me. I have nothing but good vibes for the company. ↩︎
-
I need to run a script for this because I need the timezone database name for… uh… Jekyll reasons, and as far as I can tell there’s no other way to get that on iOS. ↩︎