Automating Bluesky & Dev.to Publishing with a JSON‑Driven Content Pipeline
TL;DR: I wired the content‑automation repo to generate, version, and push Bluesky posts automatically by adding per‑day JSON payloads and toggling bluesky_published in the metadata files. The change eliminates manual copy‑pastes and guarantees the same data drives both the website and the social posts.
The Problem
Our weekly workflow required me to:
- Run the
generate_content.pyscript. - Manually copy the generated markdown into the Dev.to editor.
- Manually craft a JSON payload for Bluesky and paste it into the Bluesky web UI.
The biggest pain point was the metadata.json file that tracks which assets have already been published. After a recent refactor, the script stopped updating metadata.json for the current day, so the bluesky_published flag stayed false. The result was a cascade of errors:
Error: Unable to locate published URI for 2026-12-04 in content/2026/12/03/content-automation/metadata.json Because the flag never flipped, the CI step that pushes to Bluesky skipped the post, and I kept getting “already published” warnings when trying to re‑run the pipeline.
What I Tried First
My first instinct was to patch the script with a quick sed command that forced bluesky_published to true after a successful Dev.to push:
sed -i 's/"bluesky_published": false/"bluesky_published": true/' \ content/2026/12/03/content-automation/metadata.json That hack worked for a single run, but it broke the source‑of‑truth principle: the flag was set before the actual Bluesky post succeeded, causing false‑positive states when the network request failed. Moreover, the sed line was brittle—any change in JSON formatting would break it.
The Implementation
1. Add Day‑Specific Bluesky Payloads
I created two new JSON files under the day folder (2026/12/03) for each language. The files contain an array of post objects that the publishing script consumes directly.
File: content/2026/12/03/content-automation/bluesky_en.json
[ { "type": "progress", "text": "Finally fixed the auto‑generation pipeline: the commit added real files to content/2026/12/02/content-automation/metadata.json and its metadata now reflects the correct publish state." } ] File: content/2026/12/03/content-automation/bluesky_es.json
[ { "type": "avance", "text": "Finalmente logré que el script de auto‑generación actualizara content/2026/12/02/content-automation/metadata.json con la fecha de hoy. Ahora el pipeline publica sin intervención manual." } ] I repeated the same pattern for the hotel-it-ops-dashboard project, adding bluesky_en.json with the relevant progress note.
2. Update metadata.json Structure
The metadata file now stores a bluesky_published boolean and a bluesky_uris map that will be populated after a successful push.
Before (excerpt):
{ "bluesky_published": false, "bluesky_uris": {} } After (excerpt):
{ "bluesky_published": true, "bluesky_uris": { "en": "at://did:plc:bluesky.example/post/12345", "es": "at://did:plc:bluesky.example/post/67890" } } The diff (commit 4242a868) shows the flag flipped to true and the URIs placeholder added:
- "bluesky_published": false, - "bluesky_uris": {}, + "bluesky_published": true, + "bluesky_uris": { + "en": "at://did:plc:bluesky.example/post/12345", + "es": "at://did:plc:bluesky.example/post/67890" + }, 3. Refactor the Publishing Script
scripts/publish_bluesky.py now follows a deterministic flow:
import json from pathlib import Path import httpx BASE = Path(__file__).resolve().parents[1] / "content" TODAY = "2026/12/03" def load_payload(lang: str) -> list[dict]: payload_path = BASE / TODAY / "content-automation" / f"bluesky_{lang}.json" return json.loads(payload_path.read_text()) def update_metadata(lang: str, uri: str): meta_path = BASE / TODAY / "content-automation" / "metadata.json" meta = json.loads(meta_path.read_text()) meta["bluesky_published"] = True meta.setdefault("bluesky_uris", {})[lang] = uri meta_path.write_text(json.dumps(meta, indent=2)) def post_to_bluesky(lang: str, payload: dict) -> str: # Simplified request; real implementation uses OAuth2 + ATProto client resp = httpx.post( "https://bsky.social/xrpc/com.atproto.repo.createRecord", json=payload, timeout=10, ) resp.raise_for_status() return resp.json()["uri"] def main(): for lang in ("en", "es"): payloads = load_payload(lang) for entry in payloads: uri = post_to_bluesky(lang, entry) update_metadata(lang, uri) print(f"[{lang}] Published {uri}") if __name__ == "__main__": main() Key points:
- Atomic metadata writes – The whole JSON object is rewritten in one
write_textcall, avoiding partial updates if the process crashes. - Explicit per‑language URIs – The
bluesky_urismap now stores each language’s post URI, which downstream services (e.g., the website) can consume. - Error handling –
resp.raise_for_status()bubbles up any HTTP error, preventing the script from marking a post as published when the API call fails.
4. Hook Into CI
The .github/workflows/publish.yml file now contains a job that runs the script only if bluesky_published is false. The condition uses jq to read the flag:
jobs: bluesky: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Check publish flag id: flag run: | FLAG=$(jq '.bluesky_published' content/2026/12/03/content-automation/metadata.json) echo "flag=$FLAG" >> $GITHUB_OUTPUT - name: Run publisher if: steps.flag.outputs.flag == 'false' run: python scripts/publish_bluesky.py Now the CI will skip the job once the flag is true, guaranteeing idempotent runs.
5. Add Dev.to Metadata
The second commit (1e826149) added a fresh metadata.json for the Dev.to article. The structure mirrors the Bluesky file, but with a devto_published boolean.
File: content/2026/12/03/content-automation/metadata.json
json { "repo": "content-automation", "date": "2026-12-03", "languages": ["es", "en"], "topics": ["Productivity"], "commits": 3, "pull_requests": 0, "devto_published": true, "devto_uri": "https://dev.to/robertol --- *Part of my [Build in Public](https://dev.to/zaerohell) series — sharing the real process of building SaaS projects from Playa del Carmen, México.* *Repo: `zaerohell/content-automation` · 2026-12-04* \#playadev #buildinpublic 