Skip to content

Translate texts, guides, etc by @floriangeigl #34

Translate texts, guides, etc by @floriangeigl

Translate texts, guides, etc by @floriangeigl #34

name: Translate texts, guides, etc
run-name: Translate texts, guides, etc by @${{ github.actor }}
concurrency:
group: translate-content
cancel-in-progress: true
on:
push:
branches:
- "main"
paths:
- "UserGuide.md"
- "Advertisement.md"
- "ConnectIQStore/MeditateStoreDescription-en.txt"
- ".github/codex/prompts/translate-content.md"
- ".github/workflows/translate-content.yml"
jobs:
translate_texts:
name: Translate
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: cleanup release-translation branch
run: |
git push -d origin release-translation || echo "no remote branch to cleanup"
git branch -d release-translation || echo "no local branch to cleanup"
- name: create release-translation branch
run: |
git checkout -B release-translation
################### Store Description
- name: Translate via Codex (reads + writes files)
id: codex_translate
uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.CHATGPT_TOKEN }}
prompt-file: .github/codex/prompts/translate-content.md
codex-args: --full-auto
safety-strategy: drop-sudo
sandbox: workspace-write
model: gpt-5.4
- name: git commit && push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ./generated/
git commit -m "Update translations" || echo "No translation changes to commit"
git push -f origin release-translation
- name: create or update PR to main
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const head = `${owner}:release-translation`;
const base = 'main';
const { data: pulls } = await github.rest.pulls.list({
owner,
repo,
head,
base,
state: 'open',
per_page: 10,
});
if (pulls.length > 0) {
core.info(`PR already exists: #${pulls[0].number}`);
return;
}
const { data: pr } = await github.rest.pulls.create({
owner,
repo,
head: 'release-translation',
base,
title: 'Update translations',
body: 'Automated translation updates generated by the translation workflow.',
maintainer_can_modify: true,
});
core.info(`Created PR: #${pr.number}`);