AI · · 5 min read

How I automated my blog: 3 posts a week with free AI

I built a cheap pipeline that drafts three blog posts each week using GitHub Actions, Supabase, Gemini and Groq – all on free tiers.

A laptop screen showing a GitHub Actions workflow file and a Supabase dashboard with draft blog posts.

I've been experimenting with ways to keep my portfolio blog fresh without spending hours each week writing. The search query that finally gave me a direction was “automate blog posts with free ai”, and I built a tiny pipeline that now drafts three posts every Monday, Wednesday and Friday. The whole thing runs on GitHub Actions, stores the generated markdown in Supabase, and calls Google Gemini for the actual content, falling back to Groq when Gemini is overloaded.

Why three posts? For a small personal site, a steady rhythm helps me stay visible in search results and gives me material to share on social media. At the same time, I don't want to sacrifice quality, so I let the AI write the first draft and then I spend a few minutes editing before I hit publish. The approach also lets me test new prompts and see how the model evolves, which is useful for the other AI‑powered tools I build.

automate blog posts with free ai – the workflow

The pipeline is deliberately simple. Every night GitHub Actions triggers a workflow file that calls a small Python script. The script reads a short “topic” entry from a Supabase table, sends it to Gemini with a prompt that asks for a 800‑word blog draft, and writes the returned markdown back into another Supabase table marked as a draft. If Gemini returns an error, the script catches it and retries using the Groq API, which is also free for low‑volume use.

  • 1. Store blog topics in a Supabase table called `draft_topics`.
  • 2. GitHub Actions runs the `generate_blog.yml` workflow on a schedule.
  • 3. The Python script fetches a pending topic, calls Gemini (or Groq), and saves the markdown as a draft.
  • 4. A separate action creates a pull request with the draft file, so I can review it in GitHub.
name: Generate Blog Draft
on:
  schedule:
    - cron: '0 9 * * 1,3,5' # 09:00 UTC Mon, Wed, Fri
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - name: Install dependencies
        run: |
          pip install -r requirements.txt
      - name: Run generator
        env:
          SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
          SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
          GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
        run: python generate_blog.py

The workflow file lives in .github/workflows/generate_blog.yml and uses a cron expression `0 9 * * 1,3,5` to fire at 09:00 UTC on Monday, Wednesday and Friday. I chose UTC because it maps nicely to my local morning routine in Haryana (around 14:30 IST). The job spins up a fresh Python container, installs the requirements, and then runs the script. By keeping the container lightweight I stay within GitHub's free minutes limit, and the run usually finishes in under two minutes.

All generated posts end up as drafts in Supabase, not directly on the live site. I have a tiny admin page that lists drafts, shows a preview, and lets me edit the markdown if I need to tighten the language or add a local example. Once I'm happy, I click “publish” and the post moves to the `published_posts` table, which the Next.js front‑end reads to render the page. This extra step saved me from accidental typos and gave me a chance to add personal touches.

The first few weeks were a crash course in reading logs. My initial run failed because I had typed the wrong Supabase URL, so the script threw a connection error that I only spotted after scrolling through the Action’s output. A second failure came from Gemini’s “high demand” response, which meant the API returned a 429 status; my retry logic wasn't ready for that, so the workflow stopped. Later I discovered that the Groq model I referenced had been retired, and the script tried to call an endpoint that no longer existed.

One surprise was how sensitive the prompts are to temperature settings. I started with temperature 0.7, which gave me creative but sometimes off‑topic output. Lowering it to 0.3 made the drafts more focused and easier to edit. I also added a short “style guide” section in the prompt that asks the model to keep sentences under 20 words and to avoid jargon, which aligns with my goal of writing in plain, friendly English.

  • • Wrong Supabase URL – fixed by copying the exact URL from the Supabase project settings.
  • • Gemini “high demand” 429 – added exponential back‑off and a fallback to Groq after three attempts.
  • • Retired Groq model – updated the model name to `llama2‑70b‑chat` which is currently supported.
  • • Missing database columns – added `draft_content` and `status` fields to the `draft_posts` table and adjusted the insert query.

Each error taught me a small but valuable habit. I now check the Action logs line by line before assuming the pipeline worked, and I keep a tiny checklist of required environment variables in the repository README. Reading the error messages carefully helped me understand how each API signals rate limits or missing resources, which is a skill that transfers to any cloud‑based AI integration I work on. Debugging became less about guesswork and more about reproducing the exact request that failed.

The practical takeaway is simple: you can set up a fully automated, three‑posts‑a‑week blog using only free tiers of Gemini, Groq, GitHub Actions, and Supabase, as long as you treat the AI output as a draft rather than the final product. The pipeline saves me a couple of hours each week, and the occasional debugging session reminds me that even “free” services need careful handling.

If you want to see the code in detail, check out my post on how I use AI tools without outsourcing my thinking and the project page for my open‑source helpers at my projects. I also wrote about building a free government‑scheme finder, which uses a similar Supabase‑backed AI flow, here: free government scheme finder. Feel free to drop a note if you run into any roadblocks—I’m always happy to help a fellow coder.

Frequently asked questions

Can I automate blog posting with free AI services?

Yes. By combining free tiers of Gemini (or Groq) with GitHub Actions and a lightweight database like Supabase, you can schedule a script that generates markdown drafts and stores them for review before publishing.

What free AI APIs are suitable for generating blog drafts?

Google Gemini offers a free quota that works well for text generation, and Groq provides an alternative model that can be used as a backup when Gemini returns rate‑limit errors. Both have Python client libraries that integrate easily with a CI workflow.

How do I handle rate‑limit errors from Gemini in an automated pipeline?

Add retry logic with exponential back‑off, and configure a fallback to another model (such as Groq) after a few failed attempts. Logging the status code helps you spot 429 responses quickly and adjust the script accordingly.

Related posts