Skip to content

feat: publish blog posts on their date - #64

Merged
jorgemoralespou merged 5 commits into
developfrom
scheduled-post-publishing
Nov 24, 2026
Merged

jorgemoralespou merged 5 commits into
developfrom
scheduled-post-publishing

Conversation

@jorgemoralespou

Copy link
Copy Markdown
Contributor

Summary

A Blog post's date is its publish date. A post merged into main before its date stays out of the site until a daily deploy on that date publishes it.

astro build
  scheduledPosts()                     # astro:config:setup, builds only
    PUBLISH_DAY ||= today (UTC)        # one day for the whole build
    postDatings(src/content/posts)     # Astro's own frontmatter parser
    left out = drafts + posts dated after PUBLISH_DAY
    processor.hastPlugins += unlinkPosts(left out)
  render
    posts() -> isPublished(post, PUBLISH_DAY)
      # pages, lists, archive, tags, authors, feeds, series box, related Content
    Markdown: <a href="/blog/<left out>[#anchor]">text</a>  ->  text
06:17 UTC daily  publish-scheduled-posts.yaml       # scheduled, so it runs on develop
  checkout main
  npm run posts-due                                 # posts dated today, drafts aside
  if any: gh workflow run deploy.yaml --ref main    # needs actions: write
  • checks.yaml and external-links.yaml build with INCLUDE_FUTURE_POSTS=true, so a post is checked before it goes out and the links to it resolve.
  • PUBLISH_DAY=<YYYY-MM-DD> builds the site as it is on that day. The dev server shows every post.
  • Links to drafts are unlinked as well, since builds leave drafts out too. Nothing links to the one draft today.

Evidence

Builds of this branch with the six November posts from updates-and-blogs added (2026-11-23 to 2026-11-28):

  • Before: a build publishes every post that isn't a draft, so merging the six publishes all of them, and the forward links point at live pages.
    After, today (2026-11-24):
    [scheduled-posts] Publishing the posts dated 2026-11-24 or before
    [scheduled-posts] Leaving out educates-4-cli-config-kinds (2026-11-25), and unlinking links to it
    [scheduled-posts] Leaving out multiple-local-clusters (2026-11-26), and unlinking links to it
    [scheduled-posts] Leaving out multi-node-local-clusters (2026-11-27), and unlinking links to it
    [scheduled-posts] Leaving out extension-packages-as-image-volumes (2026-11-28), and unlinking links to it
    site check: 0 errors, 0 warnings
    637 links to /blog/, 0 dead
    
    No held-back slug or title appears anywhere in dist/: pages, Open Graph images, sitemap, RSS and Atom, tag pages, related Content, Learn data. The series box reads "Part 2 of 2".
  • Before: That has <a href="/blog/extension-packages-as-image-volumes">a post of its own</a>. (a dead link)
    After: That has a post of its own.
  • PUBLISH_DAY=2026-11-26: the 11-25 post links to 11-26 again, #upgrading-from-a-single-cluster included. 11-27 and 11-28 stay out. 711 links, 0 dead.
  • INCLUDE_FUTURE_POSTS=true: all four future posts build with their links. 766 links, 0 dead.
  • npm run posts-due -- <day>: 2026-11-23 prints installing-educates-4-with-helm, 2026-11-28 prints extension-packages-as-image-volumes, and 2026-11-29 prints nothing.
  • Dev server: serves the future posts with their links.
  • Unit tests and checks: 18 new unit tests pass (post-schedule, post-dates, unlink-posts). astro check reports 0 errors and Prettier is clean.

Merge Danger

Door: two-way

Reverting restores today's behavior. Nothing is migrated or deleted.

Blast Radius: publishing

  • Merge order: this has to reach main before or together with updates-and-blogs. Otherwise the 11-25 to 11-28 posts go live on that branch's first deploy.
  • Daily workflow: it is scheduled from develop but runs main's posts-due, so it fails each day until this is on main.
  • Frontmatter links: a link in an entry's frontmatter, such as a Feature's reading list, is not unlinked. A Featured Content id naming a held-back post fails the build. The README says to add either only once the post is out.
  • Skipped runs: GitHub can delay or skip a scheduled run. A post dated a skipped day waits for the next deploy, and running Deploy to GitHub Pages by hand publishes it.

A post's `date` is now its publish date. A build leaves out the posts
dated after its publish day, the UTC day it runs on, as it leaves out
drafts, so a post can merge before its date. PUBLISH_DAY builds the site
as it is on another day, and INCLUDE_FUTURE_POSTS=true includes the posts
of every date. The dev server still shows every post.
In a build, the scheduled-posts integration fixes the build's publish day
and adds a step to the Markdown pipeline that renders a link to a post the
build leaves out, `/blog/<slug>` with or without an anchor, as its plain
text. The feeds render posts through the same pipeline. The build that
publishes the post links to it again. It reads each post's slug, date and
draft flag with Astro's own frontmatter parser, before the content layer
loads them.
The checks and the weekly external link check build with
INCLUDE_FUTURE_POSTS=true, so a post is checked before it goes out and
the links to it resolve.
Publish scheduled posts runs daily at 06:17 UTC. It checks out main, asks
`npm run posts-due` for the posts dated that day, and when there are any,
starts Deploy to GitHub Pages on main. Scheduled workflows run on the
default branch, develop, so it dispatches the deploy rather than
deploy.yaml having a schedule of its own.
@jorgemoralespou
jorgemoralespou merged commit f834182 into develop Nov 24, 2026
1 check passed
@jorgemoralespou
jorgemoralespou deleted the scheduled-post-publishing branch November 24, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant