Skip to main content
coreydaley.dev

My blog posts now share themselves to Bluesky and LinkedIn

My posts publish themselves. I finish one, give it a future date, and a GitHub Action deploys the site that morning. I wrote about that in How this site is made now.

Sharing them didn’t work that way. Every post meant opening LinkedIn, pasting the text, adding the link as a first comment, then doing the same on Bluesky, either by hand or by having Claude drive Chrome while I watched. Yesterday I published a post at 1 AM and was still sharing it around lunchtime. That was the push to automate it.

Now the same pipeline does it. When a post goes live, a second Action posts its Bluesky and LinkedIn text through each network’s API. This post is the first one it shares, so if you came here from either site, it worked.

Why not a scheduling service?

I looked at three other ways first:

  • Claude on my Mac mini, driving Chrome, unattended. It breaks on any layout change, needs a signed-in browser, and stops after a reboot until I unlock the disk. LinkedIn’s terms also don’t allow automated clicking.
  • Postiz, an open-source scheduler you host yourself. It supports both networks, but it’s another service to run, its LinkedIn connection has the same 60-day sign-in described below, and it doesn’t know when one of my posts actually goes live.
  • Buffer. Its free plan covers three channels with ten queued posts each, but it isn’t open source, and the schedule would live in a second place.

That last point decided it. The site already knows when a post goes live. Sharing should hang off that moment, not off a second calendar I have to keep in sync.

The rule: approve at writing time

I didn’t want a bot writing posts under my name. So the social text is written and approved when the blog post is, and stored in the post’s own front matter:

[promo]
bluesky = """A teaser under 300 characters.

https://coreydaley.dev/posts/2026/11/some-post/"""
linkedin = """Hook line.

A few short paragraphs. Link in the first comment.

#Hugo #Automation"""
linkedin_comment = "What's at the link: https://coreydaley.dev/posts/2026/11/some-post/"

That table is the approval. The workflow posts it word for word and never edits it. Leave out a key and that channel is skipped; a post with no [promo] table is never shared. Hugo keeps keys it doesn’t use out of the page, so the table changes nothing on the site.

When it posts

The workflow runs whenever a deploy finishes successfully:

on:
  workflow_run:
    workflows: ["Deploy coreydaley.dev → Cloudflare Pages"]
    types: [completed]
  schedule:
    - cron: "45 13 * * *"

That covers both ways a post goes live: the morning job starting a deploy, and me pushing a post dated in the past. The 13:45 UTC run is a backstop in case the morning chain doesn’t fire it (more on that below). A small Python script then decides what’s due. A post is shared only if:

  • it isn’t a draft and its date has passed,
  • it was dated in the last three days, so adding [promo] to an old post doesn’t suddenly share it,
  • its URL returns 200, checked up to ten times, 30 seconds apart, while the deploy settles,
  • and that channel isn’t already in the ledger.

The ledger is a small JSON file in the repo mapping each post’s URL to the Bluesky and LinkedIn posts it produced. The script writes it straight after each successful post, so if LinkedIn fails after Bluesky worked, a re-run only retries LinkedIn. The workflow commits it back with the built-in GITHUB_TOKEN, and GitHub doesn’t start other workflows from that token’s pushes, so the commit doesn’t trigger another deploy.

It also checks the text first: Bluesky text over 300 characters or missing the post’s URL, a link in the LinkedIn body, or a misspelled key fails the run instead of posting something broken.

Bluesky was the easy half. An app password (in Settings, under Privacy and security) logs in without your main password and can be revoked on its own.

Posting takes two calls: com.atproto.server.createSession with the handle and app password, then com.atproto.repo.createRecord with the post. Two details matter:

  • Links aren’t automatic. A URL in the text stays plain text unless you add a facet saying which bytes are a link. The offsets count UTF-8 bytes, not characters, so an em dash earlier in the text shifts everything after it. There’s a test for exactly that.
  • The preview card is yours to build. The script reads the page’s og:title, og:description and og:image, uploads the image with uploadBlob, and attaches it as an external embed.

The second one fixes something I got wrong by hand. The first teaser I posted on Bluesky went out with no preview card, because I typed the URL into the composer instead of pasting it.

LinkedIn: the harder half

LinkedIn needs a developer app, and the app has to be linked to a company page, so I made a small one. The app needs two products, “Share on LinkedIn” and “Sign In with LinkedIn using OpenID Connect”, for the scopes w_member_social (post as me) and openid profile (find out who “me” is).

The post goes to the Posts API, POST /rest/posts, with a LinkedIn-Version header naming a monthly API version. The text uses LinkedIn’s “little text” format, where characters like (, _ and # are reserved and have to be escaped. A hashtag is written as a template:

#Hugo  →  {hashtag|\#|Hugo}

The first comment, with the link, goes to the post’s comments endpoint straight after. The link stays out of the body because posts with links are widely reported to reach fewer people.

The catch is the token. It lasts 60 days, and as far as I can tell, refresh tokens are for LinkedIn’s approved partners, not a self-serve app like mine. So every two months I sign in again. A small script on my Mac makes that one step: it opens LinkedIn’s consent page, catches the redirect on localhost, swaps the code for a token, and stores it with gh secret set. It also saves the expiry date as a repository variable, and the workflow adds a warning to its run log in the last week. Nothing notifies me of that warning yet, so it only helps if I look.

Building your own

My site’s repo is private, so I’ve put a copy you can adapt in a public repo: hugo/social-post in sandbox-public. It’s the same code with my site, repo and workflow names turned into settings, plus a README with the setup steps. The pieces:

  1. A script that reads each post’s front matter (Python’s tomllib handles TOML), picks the due posts, posts them and updates the ledger. Mine uses only the standard library. It has 23 unit tests covering the due-date rules, validation, the byte offsets, the escaping and the ledger’s retry behaviour. None of them touch the network, so the real API calls are only tested by real posts.
  2. A workflow on workflow_run after your deploy, with contents: write so it can commit the ledger.
  3. Secrets for the Bluesky app password and the LinkedIn token, and variables for the Bluesky handle, your LinkedIn member ID and the token’s expiry. Only the posting step sees the secrets.
  4. A manual run that defaults to a dry run. It prints what’s due and posts nothing.

What this post is testing

  • The morning chain. The workflow has run once for real, after a deploy I pushed. This post is the first to go out through the whole morning sequence: the schedule starts the publish job, which starts the deploy, which starts this workflow. GitHub limits what a workflow’s own token can trigger, which is why the 13:45 backstop exists.
  • The LinkedIn version header. I picked 202608 with no way to check it short of posting. If it’s wrong, the run fails with LinkedIn’s error and nothing goes out there.
  • Not quite “never twice”. The ledger stops repeats in normal failures. If LinkedIn accepted a post but returned no ID, or the ledger commit failed after a successful post, a re-run would post again. A failed first comment isn’t retried either.

And what it doesn’t do yet: attach an image on LinkedIn. A native image gets far more room in the feed than a link preview, but the source images for my posts aren’t in the repo, so posts with a strong figure still get shared by hand. The Bluesky card uses the page’s og:image, which on this site is the same cover image for every post.

Which part of shipping a post do you still do by hand, and would you trust a script with it?

Related posts