Skip to main content
  1. Posts/

Blog Bilingual Publishing Made Easy — GitHub Actions + Gemini API in Practice

·443 words·3 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

Recently, while reviewing Google Analytics, I discovered an interesting phenomenon: My blog (shenxianpeng.github.io) has decent traffic from Google Search, but the primary language of visitors is surprisingly English, with Chinese coming in second.

Language

Come to think of it, it’s not surprising—I’ve written a few good English articles before, such as Using Gcov and LCOV for C/C++ Code Coverage, attracting many overseas readers.

However, the problem is: I mainly write in Chinese, only occasionally in English. If readers want to see a version in another language, I have to manually translate, copy, paste, preview, and submit… The whole process is tedious and time-consuming.

So I thought: Let’s automate this with AI.


My Solution
#

Using GitHub Actions + Gemini API to achieve automatic bilingual blog publishing.

The overall idea is simple:

  1. Every time I write a new article and commit it to the repository, GitHub Actions will be automatically triggered;
  2. The workflow calls the Gemini API to translate the Chinese text into English;
  3. The translated article is committed to a new branch, and a PR is automatically created;
  4. Netlify deploys a preview; I can review it on GitHub and merge it with one click;
  5. After merging, the English version of the article will be published.

Result

This way, I only need to focus on writing in Chinese, and the English version will be generated automatically.


Core Configuration
#

Here’s the core configuration of GitHub Actions (simplified version):

on:
  push:
    paths:
      - 'content/posts/**/*.md'
      - 'content/misc/**/*.md'
  schedule:
    - cron: '0 2 * * *' # Prevents missed translations and controls API call frequency
  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 }}

I put the dependencies and translation logic in the Makefile:

install-deps:
	pip3 install -r requirements.txt

translate:
	python3 .github/auto_translate.py

Results and Inspiration
#

The final result is excellent:

Effortless: No need for manual translation and copy-pasting; Efficient: An English version is generated almost simultaneously with a Chinese article; Cost-effective: Using Gemini API + Netlify, the cost is almost zero.

More importantly, many “seemingly troublesome little things” can be solved through AI + automation. Writing a blog is just one example; extending this idea, it can be applied to many scenarios: For example, bilingual support for technical documentation, internationalization of team knowledge bases, or even translation of internal company wikis.

Conclusion
#

Don’t waste time on “repetitive work”—let tools and automation handle it; save your energy for more creative things.

If you also have the habit of writing blogs or documents, I hope this article will inspire you.

Complete code here 👉 GitHub Repository

Related

Four Years of Open Source —— Three Unexpected Rewards
Some say open source is useless, yielding neither profit nor time savings. But through four years of dedication, I’ve discovered three unexpected rewards: increased visibility for my work, connections with exceptional people and projects, and the accumulation of long-term value. These rewards are applicable to every developer.
Jenkins Explain Error Plugin Now Supports Google Gemini! 🤖
·310 words·1 min
This article introduces a new feature of the Jenkins Explain Error Plugin that supports for Google Gemini model for error analysis. It provides configuration methods and an example video.
DevOps Maturity — From Reflection to Open Source Practice
·407 words·2 mins
How to assess and improve your team’s DevOps maturity. Official release of the DevOps Maturity open source project, with assessment tools and practical guides.
Eight Years Later, I Finally Revamped My Blog
·502 words·3 mins
This article records the process of revamping my blog after eight years, from migrating from Hexo to Hugo, to the functional and design improvements of the new blog.
Jenkins Plugin Center Didn't Have an AI Plugin Yet? I Wrote One! 🤖
·751 words·2 mins
Introducing my first Jenkins plugin: Explain Error Plugin. It automatically analyzes build failure log information and generates readable error explanations, helping developers locate and solve problems faster.
A Year Abroad — Not Everyone Is Cut Out for Europe
·1474 words·3 mins
Who is suited to developing their career in Europe, and who might find it challenging? A programmer and father shares his experiences of life abroad.