Automate Bilingual Blog Publishing with GitHub Actions and Gemini AI
I automated bilingual blog publishing by using GitHub Actions to trigger Gemini AI translation of Chinese posts, automatically creating English pull requests, previewing via Netlify, and publishing the translated version, saving time, reducing cost, and demonstrating how AI‑driven automation can streamline documentation workflows.
While reviewing Google Analytics, I noticed that my blog receives a good amount of traffic from English-speaking visitors, with Chinese being the second most common language.
Because I usually write posts in Chinese and only occasionally in English, manually translating each article is tedious.
To solve this, I automated the bilingual publishing process using AI and CI/CD.
My Solution
Use GitHub Actions + Gemini API to automatically generate English versions of my blog posts.
The overall workflow is simple:
When I push a new post to the repository, GitHub Actions is triggered.
The workflow calls the Gemini API to translate the Chinese content into English.
The translated article is committed to a new branch and a pull request is opened automatically.
Netlify builds a preview; after I review it on GitHub, I can merge the PR with one click.
Once merged, the English version is published.
Core Configuration
Below is a trimmed version of the GitHub Actions workflow:
on:
push:
paths:
- 'content/posts/**/*.md'
- 'content/misc/**/*.md'
schedule:
- cron: '0 2 * * *' # prevent missed translations and control API rate
workflow_dispatch:
jobs:
check-and-translate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: make install-deps
- run: make translate
env:
GEMINI_API_KEY: ${{secrets.GEMINI_API_KEY}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}The dependency installation and translation logic are defined in the Makefile:
install-deps:
pip3 install -r requirements.txt
translate:
python3 .github/auto_translate.pyFull source code is available at https://github.com/shenxianpeng/blog .
Results and Takeaways
The automation delivers three main benefits:
Convenient : No manual copy‑paste translation.
Efficient : English versions appear almost instantly after the Chinese post is written.
Cost‑free : Using Gemini API and Netlify incurs no extra expense.
More importantly, many seemingly tedious tasks can be solved with AI + automation. The same approach can be extended to bilingual documentation, internationalized knowledge bases, or internal wiki translation.
Final Thought
Don’t waste time on repetitive work—let tools and automation handle it so you can focus on creativity.
If you maintain a blog or documentation, I hope this article inspires you.
DevOps Engineer
DevOps engineer, Pythonista and FOSS contributor. Created cpp-linter, commit-check, etc.; contributed to PyPA.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
