|
| 1 | +# Automated Weekly Social Posts — Specification |
| 2 | + |
| 3 | +## Problem |
| 4 | +Post one pattern per week to X/Twitter and Bluesky, covering all 112 patterns (~2 years of content). Fully automated via GitHub Actions with no manual steps. |
| 5 | + |
| 6 | +## Approach |
| 7 | +Use a **GitHub Actions scheduled workflow** that: |
| 8 | +1. Reads a pre-shuffled queue file (`content/social-queue.txt`) listing all pattern keys |
| 9 | +2. Each week, picks the next unposted pattern, posts to X and Bluesky |
| 10 | +3. Commits the updated queue pointer back to the repo to track progress |
| 11 | +4. When all 112 are exhausted, reshuffles and starts over |
| 12 | + |
| 13 | +### Why a queue file? |
| 14 | +- Deterministic: you can review/reorder upcoming posts |
| 15 | +- Resumable: survives workflow failures, repo changes |
| 16 | +- Auditable: git history shows what was posted when |
| 17 | + |
| 18 | +## Post Format |
| 19 | +``` |
| 20 | +☕ {title} |
| 21 | +
|
| 22 | +{summary} |
| 23 | +
|
| 24 | +{oldLabel} → {modernLabel} (JDK {jdkVersion}+) |
| 25 | +
|
| 26 | +🔗 https://javaevolved.github.io/{category}/{slug}.html |
| 27 | +
|
| 28 | +#Java #JavaEvolved |
| 29 | +``` |
| 30 | + |
| 31 | +## Implementation |
| 32 | + |
| 33 | +### 1. Social Queue Generator |
| 34 | +**File:** `html-generators/generate-social-queue.java` |
| 35 | + |
| 36 | +JBang script that reads all content files, shuffles them, and writes `content/social-queue.txt` (one `category/slug` per line). |
| 37 | + |
| 38 | +### 2. Social Post Script |
| 39 | +**File:** `html-generators/social-post.sh` |
| 40 | + |
| 41 | +Shell script that: |
| 42 | +- Reads the next unposted line from `content/social-queue.txt` |
| 43 | +- Loads the pattern's JSON/YAML to build the post text |
| 44 | +- Posts to X/Twitter via API v2 (OAuth 1.0a) |
| 45 | +- Posts to Bluesky via AT Protocol API |
| 46 | +- Updates the pointer file (`content/social-queue-pointer.txt`) |
| 47 | + |
| 48 | +### 3. GitHub Actions Workflow |
| 49 | +**File:** `.github/workflows/social-post.yml` |
| 50 | + |
| 51 | +- Schedule: weekly cron (e.g., Tuesday 15:00 UTC) |
| 52 | +- Runs the post script |
| 53 | +- Commits updated queue state back to repo |
| 54 | + |
| 55 | +## Required GitHub Secrets |
| 56 | +| Secret | Purpose | |
| 57 | +|--------|---------| |
| 58 | +| `TWITTER_API_KEY` | X API v2 OAuth 1.0a consumer key | |
| 59 | +| `TWITTER_API_SECRET` | X API v2 OAuth 1.0a consumer secret | |
| 60 | +| `TWITTER_ACCESS_TOKEN` | X API v2 user access token | |
| 61 | +| `TWITTER_ACCESS_SECRET` | X API v2 user access secret | |
| 62 | +| `BLUESKY_HANDLE` | Bluesky handle (e.g., javaevolved.bsky.social) | |
| 63 | +| `BLUESKY_APP_PASSWORD` | Bluesky app password | |
| 64 | + |
| 65 | +## Design Decisions |
| 66 | +- **Text-only posts** with URL — platforms unfurl the OG card automatically from `og:image` meta tags |
| 67 | +- **Random order** via pre-shuffled queue for variety across categories |
| 68 | +- **Reshuffles** when all 112 patterns are exhausted |
| 69 | +- **Post script uses `curl`** for both APIs (no extra dependencies) |
| 70 | +- **Queue state** tracked via a pointer file containing the current line number |
0 commit comments