skip to content
Jerrie Pelser's Blog

How I publish scheduled content with Relay.app

/ 6 min read

Introduction

I am using Astro as a static site generator for this blog. Every few weeks, I will sit down for a day or two and write the blog posts for the next month or so. I have configured my blog posts collection in Astro to only publish blog posts when the publication date is in the past.

Since the publication date for these blog posts I write in advance are in the future, the static pages for those blog posts will not be generated when I run the Astro build process.

So, what I need is a way to trigger the build and deployment of the website whenever a blog post has reached its publication date. In this blog post, I will discuss how I have automated this process.

Using a Vercel Deployment Hook

The source code for this blog is hosted in a GitHub repository, and I am using Vercel for the hosting. I have also connected the GitHub repository to Vercel, creating an automated deployment. Every time I push changes to the GitHub repository, the Vercel build will be triggered and the new version of the blog will be deployed.

However, as I mentioned in the introduction, blog posts where the publication date is in the future, will not be published. I therefore need a way to trigger the build at a specified time.

Since I am using Vercel, I can create a Deploy Hook. Deploy Hooks are HTTP endpoints that you can make an HTTP POST request to in order to initiate a build.

Create a Deployment Hook in Vercel

With a Deploy Hook created, I know need to trigger it at a specified time.

Creating the Relay.app workflow

My initial thought was that I need some way to determine when a certain blog post is due and, at that time, trigger a deployment using the Vercel Deploy Hook.

Luckily this idea was quickly abandoned as it was overcomplicating something that is very simple. New blog posts are published once or twice a week, so the easiest and most effective solution was to simply trigger the Deploy Hook once a day.

For this I used Relay.app. Relay.app is an automation tool very similar to Zapier. They came on my radar a while back, and I started using them for a few workflow automations.

One of the things that make them stand out from the other players in this market is their Human-in-the-loop feature which allows you to add checkpoints in your workflow that require approval by a human. I won’t be using this feature in this blog post, but it was one of the things that first brought them to my attention.

The workflow itself is pretty simple. I have a trigger that runs on a certain schedule and makes and HTTP request.

The publishing workflow in Relay.app

The trigger runs once a day at 8 AM my time - which is 1 AM UTC.

The publishing workflow trigger

The custom HTTP request calls the Vercel Deploy Hook endpoint that I created previously.

The publishing workflow HTTP request

With that in place, I have a very simple workflow that triggers a new Vercel build once a day, ensuring that scheduled blog posts are available on my blog at the scheduled time.

If you need more granular deployments

A simple CRON job like the one I created above will probably be sufficient in 99% of the cases. However, there may be rare instances where it may be necessary to trigger deployments at a very specific time.

Let’s say you work for a company that requires product pages for a new product to be published at a specific time. Perhaps your CEO will make an announcement at a conference and the new product pages must be available immediately after this announcement.

Assuming you are using a similar combination of Astro + Vercel + GitHub as your technology stack, there are a few ways you can handle this.

  1. The easiest way is to create a pull request (PR) on GitHub that contains the updates and have someone merge the PR right as your CEO announces the product on stage. Merging the PR will trigger the Vercel build which will publish the updates to the website.
  2. You can also schedule the merging of the PR using tools such as the Merge Schedule GitHub action or the PR Scheduler app.
  3. Another option could be to use a Headless CMS for managing your content, rather than markdown files in your GitHub repository. For example, Contentful allows you to schedule content to be published at a certain time. This can be used along with their webhook functionality to trigger the deployment on Vercel.

My post-publication workflow

I also have a few actions that must be taken after a new blog post is published. I tried to make this once fancy as well doing all sorts of automation and having AI write catchy X (Twitter) and LinkedIn posts for me and schedule those posts at a certain time, but I could not get it quite right.

In the end I settled once again for the simple but effective solution: email myself with the post-publication actions I must take.

For this workflow I use the “New Item in RSS feed” trigger to send an email.

The post-publication workflow

The trigger monitors my blog’s RSS feed for new items.

The RSS feed trigger

When a new item is published, the workflow emails me with a reminder of the steps I must take, namely ensuring the new page is indexed on Google Search Console, and the proposed text for a couple of X and LinkedIn posts that I schedule with Buffer.

The email step

It does not completely automate the process, but doing these manual actions take me a couple of minutes once a week. If I published many blog posts a day and it took a lot of time to do this, I would spend more time and effort to completely automate it.

Conclusion

In this blog post, I demonstrated how I automate the publishing of scheduled post for my Astro blog, as well the follow-up actions I have to take after a new blog post is published. It is not a complicated process, but it means that I don’t have to remember to manually trigger a new deployment of my website when new blog posts are ready to go live.