📜 ci: Consolidate Locize Workflows for Missing Keys & PR Creation (#5769)

This commit is contained in:
Ruben Talstra 2025-02-10 15:03:59 +01:00 committed by GitHub
parent 37f6099f0a
commit d90c9c4b77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 35 deletions

73
.github/workflows/locize-i18n-sync.yml vendored Normal file
View file

@ -0,0 +1,73 @@
name: Push New Keys & Create Translation PR
on:
push:
branches: [main]
repository_dispatch:
types: [locize/versionPublished]
jobs:
push-new-keys:
name: Push Missing Translation Keys to locize
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install locize CLI
run: npm install -g locize-cli
# Only push keys if this workflow was triggered by a push event.
- name: Push Missing Translation Keys to locize
if: ${{ github.event_name == 'push' }}
run: |
cd client/src/locales
locize save-missing --api-key ${{ secrets.LOCIZE_API_KEY }} --project-id ${{ secrets.LOCIZE_PROJECT_ID }} --language en
# When triggered by repository_dispatch, skip pushing new keys.
- name: Skip push step on non-push events
if: ${{ github.event_name != 'push' }}
run: echo "Skipping push of new keys as the event is not a push."
create-pull-request:
name: Create Translation PR on Version Published
runs-on: ubuntu-latest
# This job will wait for push-new-keys to complete.
needs: push-new-keys
permissions:
contents: write
pull-requests: write
steps:
# 1. Check out the repository.
- name: Checkout Repository
uses: actions/checkout@v4
# 2. Download translation files from locize.
- name: Download Translations from locize
uses: locize/download@v1
with:
project-id: ${{ secrets.LOCIZE_PROJECT_ID }}
path: "client/src/locales"
# 3. Create a Pull Request using built-in functionality.
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
sign-commits: true
commit-message: "🌍 i18n: Update translation.json with latest translations"
base: main
branch: i18n/locize-translation-update
reviewers: danny-avila
title: "🌍 i18n: Update translation.json with latest translations"
body: |
**Description**:
- 🎯 **Objective**: Update `translation.json` with the latest translations from locize.
- 🔍 **Details**: This PR is automatically generated upon receiving a versionPublished event with version "latest". It reflects the newest translations provided by locize.
- ✅ **Status**: Ready for review.
labels: "🌍 i18n"