This repository includes automation to help prepare content for social media platforms. The automation:
- Extracts and verifies code from markdown posts
- Formats content with separate handling for Twitter threads and LinkedIn posts
- Generates code images using carbon-now-cli
- Outputs files ready for manual upload to Hypefury
- Run the setup script to install required dependencies:
./scripts/setup.sh- Process any markdown post:
uv run scripts/prepare_social_post.py tips/001_bulkhead.md --output output/tip001-
The script will:
- Extract code blocks and verify they're syntactically valid
- Generate distinctly styled code images for BEFORE/AFTER examples
- Create Twitter thread format (first tweet with hook, second with solution)
- Create full-content version for LinkedIn
- Save everything to the specified output directory
-
Review and manually upload to Hypefury:
- Check the generated files in the output directory
- For Twitter: Use the 2-part thread format:
twitter_1.txt: Hook and introduction (attach both BEFORE/AFTER images)twitter_2.txt: Solution and takeaway, with hashtags
- For LinkedIn: Use the
linkedin.txtfile (attach all code images) - All content starts directly with the hook (no title)
A GitHub Actions workflow is also set up to automatically process markdown files when they're pushed to the main branch. The workflow:
- Detects changed markdown files in the
tips/directory - Processes each file to generate social media content
- Uploads the results as artifacts that you can download
You can also manually trigger the workflow for a specific file via the GitHub Actions UI.
tips/
│
├── scripts/ # Automation scripts
│ ├── process_post.py # Processes markdown files
│ ├── generate_images.py # Generates code images
│ ├── prepare_social_post.py # Main orchestration script
│ └── setup.sh # Setup script
│
├── output/ # Generated output
│ └── tip001/ # Output for each tip
│ ├── images/ # Generated code images
│ │ ├── tip001_BEFORE_1.png # "Before" code image
│ │ └── tip001_AFTER_1.png # "After" code image
│ ├── twitter_1.txt # First tweet in thread (hook + intro)
│ ├── twitter_2.txt # Second tweet in thread (solution + takeaway)
│ ├── linkedin.txt # Content for LinkedIn
│ └── summary.json # Summary of processing
│
└── .github/workflows/ # GitHub Actions workflow
└── prepare-social.yml # Workflow definition
- Direct integration with Hypefury API
- Further optimization of thread content for Twitter
- Automated scheduling of posts
- Support for additional platforms
- Image optimization for social media
-
Write your markdown post in the
tips/directory using the new template format:- Make sure code blocks use
# BEFORE:and# AFTER:comments to label them - Structure content with proper headings (### The Problem, ### The Solution, etc.)
- Include a strong hook in bold at the beginning
- Make sure code blocks use
-
Run the script to process the post:
uv run scripts/prepare_social_post.py tips/your_post.md
-
Review the generated content in the output directory:
- Check that the Twitter thread flows properly
- Ensure the BEFORE/AFTER code images are generated correctly
- Verify the LinkedIn post has the complete content
-
Log in to Hypefury and create posts:
a. For Twitter:
- Create a thread by pasting the content from each tweet file in order
- Attach the BEFORE and AFTER code images to the first tweet
- Review thread for proper formatting
b. For LinkedIn:
- Create a post using the content from linkedin.txt
- Attach all code images in the correct order
- Review post for proper formatting
-
Schedule the posts for your desired time
- Code verification fails: The script only checks syntax, not execution. If you get verification failures, check that the code is syntactically valid.
- Image generation with carbon-now-cli:
# Install carbon-now-cli npm install -g carbon-now-cli # For each code segment, use: carbon-now examples/tip001.py # The script will find the generated images and move them to the output directory # Look for output like: The file can be found here: /path/to/tip001-AbCdEfG.png
- Images not appearing in output directory: The script will automatically find and move images generated by carbon-now-cli. These image names will look like
tip001-AbCdEfG.png(with a random suffix). Make sure you run carbon-now before or after running the script. - Import errors: Make sure you're running the script with
uv runfrom the root directory.