Publish Drafts on a Schedule

I’ve been using Jekyll and a third-party theme since August 2018 to publish my blog using GitHub Pages. I truly enjoy the fact that it’s a static site and is built using easy-to-understand markdown. I’m no Jekyll Pro, but I have modified the theme a bit and created my own data file for a particular page.

A few months ago, I was asked to participate in a blog event and needed to schedule the publication of a couple posts. At the time, I didn’t have spare time to make that happen, so I dutifully pushed my drafts at odd hours and lost a bit of sleep.

I did, however, discover a GitHub Action called Jekyll Publish Drafts. Over the last few days, I finally spent the time to get this working and have written a post about it.

If you use GitHub Pages for your Jekyll site and need to schedule the publication of a post at a specific time, check out my post Publish a Post for a Jekyll Site on a Schedule.

I welcome comments or suggestions. Just leave them here, in the post comments, or on Twitter (same handle as here).

Thanks,
Dave

1 Like

Thanks for sharing.

I discovered the cron option recently so I want to use it for nightly or weekly runs.

The article looks well laid out and detailed.

Maybe I am missing something - what was the reason for using the Drafts flow and action? Rather than a generic one.

My understanding is that you can put a post in _posts folder and it will not be published unless the --future flag is used (such as for local testing). Then you don’t need to more or rename posts. You rebuild every day and then the future dated posts then becomes current and so appears.

I have a demo here which uses and references the Jekyll Actions action (similar to the one you used but more generic than draft-related). Perhaps this would work too for your case.

1 Like

First, thanks for checking out the article!

Basically, the Jekyll Publish Drafts GitHub Action was the first thing that came up in my searches. And honestly, until I started working on this, I wasn’t aware of the future flag.

I suppose between the action that I’m using and your action, the one I’m using does not rebuild the site unless there is a scheduled post. Unless I’m mistaken, the action you use rebuilds on the schedule. Is this correct?

In my CI, after the site is built and pushed into gh-pages branch, it pings Google and Bing with the updated sitemap.xml.

As a PowerShell advocate, I’d like to see some Jekyll actions that would use PowerShell to do the automation. If I have spare time, I might look into doing just that.

Thanks again.

The one I recommended rebuilds on a push, or pull request or schedule - depending what you configure in workflow for on. It it is independent of posts and dates

My demo builds on every push to master. There is no posts directory

I thought GH actions and docker run linux only and not powershell

This page says Windows works on actions https://github.com/features/actions

From my GitHub Action setup job step, I see the following:

Current runner version: ‘2.169.1’
Operating System
Ubuntu
18.04.4
LTS
Virtual Environment
Environment: ubuntu-18.04
Version: 20200430.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu18/20200430.1/images/linux/Ubuntu1804-README.md

From the link, it shows that the underlying ubuntu has PowerShell 7 installed. PowerShell 7 is built on .net Core 3.1 which is cross-platform. Most of the CI platforms now support PowerShell 7 on their linux systems as well.

Oh thanks for info. I thought it was Windows only

1 Like