The recent changes I made to my blog to add microblogging support included setting up a Micropub to GitHub web service. This allows me to use the Micro.blog app (or any other Micropub-compatible app) to compose and publish new microposts. However, the web service doesn't currently support a Micropub media endpoint, so I can't attach photos to new microposts using the Micro.blog app.
Once again, Workflow to the rescue! I've created this workflow for publishing microposts on my Jekyll-powered blog that can also include photos. Instead of relying on the Micropub to GitHub service, it uses GitHub's API to directly upload and commit the micropost–and attached photos–to my blog's repository. This automatically triggers a site deploy on Netlify, making the new micropost and photos available a few moments later.
When run, the workflow does the following:
- Prompts me to write a new micropost.
- If the workflow was not run as an action extension, it asks if I want to add any photos (the workflow checks if any photos were shared when run). I can then select photos from my library.
- Resizes all photos to 1000px wide. Photos that are already smaller than 1000px are not resized. I don't want to share full-size photos, so reducing the size suits my needs.
- Asks me to confirm or change the file name for each photo.
- Uploads the photos to my GitHub repository and commits the changes, triggering a deploy with Netlify.
- Creates the micropost text file with the composed text and current date. If photos have been included, Markdown-formatted photo links are added at the end of the text file. This text file is uploaded and to GitHub and committed. Netlify then does another deploy, making the post available.
Although I created this workflow primarily as a way to publish photos, I can also use it to quickly publish text-only microposts. What's more, I can even dictate new microposts and publish them straight from my Apple Watch.
If you wish to customize the workflow, change the following parameters in the Dictionary action at the top of the workflow:
token: A GitHub token that has read/write access to your repositories.
username: Your GitHub username.
repo: Your site's Repository.
directory: The directory to save images to.
site_url: The URL to the website.
post_dir: The directory where micropost text files should be saved to.
The configuration options have been created based upon my implementation of microposts. Depending on how (and where) you publish microposts, you might need to make some additional changes to the workflow.