Build Tales Automation Setup Guide
This guide will help you set up automated publishing to Medium, Substack, and other social media platforms via Zapier using GitHub’s free image hosting.
Overview
The automation system:
- Renders Mermaid diagrams to SVG/PNG
- Saves images to your repository (free GitHub hosting)
- Generates GitHub image URLs automatically
- Compiles Markdown with image fallbacks
- Generates social media snippets
- Publishes to Medium (via API)
- Prepares Substack content (manual publishing)
- Triggers Zapier for other platforms
Why GitHub Images?
- 💰 Completely Free: No storage or bandwidth costs
- 🚀 Integrated: Works seamlessly with your GitHub workflow
- 🌐 Global CDN: GitHub serves images worldwide
- 📝 Versioned: Images are tied to your repository commits
- 🔒 Reliable: GitHub’s infrastructure handles the heavy lifting
Prerequisites
- Node.js 20+ installed
- GitHub repository with Actions enabled
- Medium API access (optional)
Quick Start
- Install dependencies:
npm ci - Test locally:
npm run ci:all - Check output:
assets/diagrams/- Rendered SVG/PNG imagesassets/diagrams-manifest.json- GitHub image URLsdist/- Compiled Markdown with image fallbacksdist/social-snippets.json- Social media snippetsdist/medium-publish-results.json- Medium publishing resultsdist/substack/- Substack-ready markdown files
Environment Variables
Required for Medium Publishing
MEDIUM_ACCESS_TOKEN=your_medium_token
MEDIUM_USER_ID=your_medium_user_id
Optional for Zapier
ZAPIER_HOOK_URL=https://hooks.zapier.com/hooks/catch/your-webhook
Medium API Setup
- Get Access Token:
- Go to Medium Settings > Integration tokens
- Generate a new integration token
- Copy the token
- Get User ID:
- Make a request to:
https://api.medium.com/v1/me - Use your access token in Authorization header
- Extract
data.idfrom the response
- Make a request to:
- Test API Access:
curl -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ https://api.medium.com/v1/me
GitHub Setup
Repository Structure
Your repository will automatically create:
assets/
diagrams/ # Rendered Mermaid diagrams
diagrams-manifest.json # GitHub image URLs
dist/ # Compiled content
*.md # Markdown with image fallbacks
social-snippets.json
medium-publish-results.json
substack/
Image URLs
Images are automatically available at:
https://raw.githubusercontent.com/USERNAME/REPO/main/assets/diagrams/filename.svg
GitHub Secrets Setup
- Go to your repository settings
- Navigate to Secrets and variables > Actions
-
Add the following secrets:
MEDIUM_ACCESS_TOKEN MEDIUM_USER_ID ZAPIER_HOOK_URL (optional)
Zapier Setup
Trigger Options
- Webhook Trigger (Recommended):
- Use “Catch Hook” from Webhooks by Zapier
- Copy the webhook URL to
ZAPIER_HOOK_URLsecret - GitHub Actions will POST to this URL
- GitHub Actions Artifact Trigger:
- Use “New Artifact in GitHub Actions” trigger
- Select your repository and workflow
- Trigger on new artifacts
Action Mappings
- App: LinkedIn
- Action: Create post
- Content: ``
Twitter/X
- App: Twitter
- Action: Create multiple tweets (thread)
- Tweets:
- Tweet 1: ``
- Tweet 2: ``
- Tweet 3: ``
- App: Facebook Pages
- Action: Create page post
- Content: ``
Mastodon
- App: Webhooks by Zapier
- Action: Custom request
- URL:
https://your-instance.com/api/v1/statuses - Method: POST
- Data:
{"status": ""}
Content Structure
Frontmatter Requirements
For best results, include these fields in your Markdown frontmatter:
---
title: "Your Article Title"
tags: ["engineering-leadership", "fintech", "payments"]
categories: ["payments"]
canonical_url: "https://buildtales.dev/your-article-url"
---
Mermaid Diagrams
The system automatically:
- Renders ````mermaid` blocks to SVG
- Saves to
assets/diagrams/in your repo - Generates GitHub image URLs
- Inserts image fallbacks
- Maintains original mermaid blocks
Example:
```mermaid
graph TD
A[Start] --> B[Process]
B --> C[End]
```
Workflow Commands
Local Development
# Render diagrams only
npm run ci:render
# Generate GitHub image URLs only
npm run ci:github-urls
# Build markdown only
npm run ci:build
# Generate snippets only
npm run ci:snippets
# Publish to Medium only
npm run ci:medium
# Prepare Substack content only
npm run ci:substack
# Run complete pipeline
npm run ci:all
# Run complete pipeline + publishing
npm run ci:publish
GitHub Actions
The workflow runs automatically on:
- Push to
mainbranch - Changes to
content/**/*.md - Changes to
tools/** - Changes to
package.json
Automatically commits:
- Generated diagrams to
assets/diagrams/ - Updated image manifest
- Built artifacts to
dist/
How It Works
- Push article → GitHub Actions triggers
- Mermaid renders → SVG files saved to
assets/diagrams/ - GitHub URLs generated →
assets/diagrams-manifest.json - Markdown compiles → Images linked via GitHub raw URLs
- Content builds → Ready for publishing
- Medium publishes → Via API (optional)
- Substack prepared → Markdown files ready
- Zapier triggered → For other platforms
Troubleshooting
Common Issues
- Medium API Errors:
- Verify access token is valid
- Check user ID is correct
- Ensure token has write permissions
- Images Not Loading:
- Check
assets/diagrams-manifest.jsonexists - Verify images were committed to repository
- Check GitHub raw URLs are accessible
- Check
- Mermaid Rendering Issues:
- Check Chromium installation
- Verify mermaid syntax
- Check output directory permissions
- Zapier Not Triggering:
- Verify webhook URL is correct
- Check GitHub Actions are running
- Test webhook manually
Debug Mode
Enable verbose logging:
DEBUG=* npm run ci:all
Manual Testing
Test individual components:
# Test Medium API
curl -H "Authorization: Bearer $MEDIUM_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
https://api.medium.com/v1/me
# Check generated images
ls -la assets/diagrams/
cat assets/diagrams-manifest.json
Customization
Adding New Platforms
- Create new tool:
tools/publish-platform.mjs - Add script: Update
package.json - Update workflow: Add step to
.github/workflows/publish.yml - Add environment variables: Update secrets
Custom Content Processing
Modify tools/compile-markdown.mjs to:
- Add custom frontmatter
- Transform content format
- Insert platform-specific metadata
Custom Diagram Themes
Update tools/render-mermaid.mjs:
npm run ci:render -- --theme dark
npm run ci:render -- --image-type png
Performance Considerations
- Rate Limiting: Medium allows 10 requests/minute
- File Sizes: Large diagrams may slow rendering
- GitHub Limits: Repository size limits apply
- Parallel Processing: Consider for large article sets
Security Notes
- Never commit API tokens to version control
- GitHub Actions run in isolated environment
- Images are publicly accessible (by design)
- Monitor repository size and commit history
Support
For issues or questions:
- Check GitHub Actions logs
- Review generated artifacts
- Test individual components
- Check environment variables
- Verify API permissions
Next Steps
- Set up Medium API access (optional)
- Configure GitHub secrets
- Test locally with
npm run ci:all - Push to trigger GitHub Actions
- Set up Zapier workflows
- Monitor and optimize
Cost Comparison
| Service | GitHub Images | S3 + CloudFront |
|---|---|---|
| Storage | Free | $0.023/GB/month |
| Bandwidth | Free | $0.085/GB |
| CDN | Free | $0.0075/10k requests |
| Setup | None | IAM, bucket policies |
| Total | $0/month | $5-50+/month |
GitHub Images save you $60-600+ annually!