Skip to content

Latest commit

 

History

History
130 lines (100 loc) · 5.06 KB

File metadata and controls

130 lines (100 loc) · 5.06 KB

Social Media Post Automation

This repository includes automation to help prepare content for social media platforms. The automation:

  1. Extracts and verifies code from markdown posts
  2. Formats content with separate handling for Twitter threads and LinkedIn posts
  3. Generates code images using carbon-now-cli
  4. Outputs files ready for manual upload to Hypefury

Getting Started

Local Setup

  1. Run the setup script to install required dependencies:
./scripts/setup.sh
  1. Process any markdown post:
uv run scripts/prepare_social_post.py tips/001_bulkhead.md --output output/tip001
  1. 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
  2. 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.txt file (attach all code images)
    • All content starts directly with the hook (no title)

GitHub Actions Workflow

A GitHub Actions workflow is also set up to automatically process markdown files when they're pushed to the main branch. The workflow:

  1. Detects changed markdown files in the tips/ directory
  2. Processes each file to generate social media content
  3. 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.

File Structure

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

Future Enhancements

  • 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

Manual Steps (Current Workflow)

  1. 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
  2. Run the script to process the post:

    uv run scripts/prepare_social_post.py tips/your_post.md
  3. 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
  4. 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
  5. Schedule the posts for your desired time

Troubleshooting

  • 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 run from the root directory.