Skip to content

sync-translations

sync-translations #8

name: Sync Translations from Google Sheets
on:
repository_dispatch:
types: [sync-translations]
workflow_dispatch: # Allow manual triggering from GitHub UI
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: '10.7.1'
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Sync translations from Google Sheets
env:
GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
TRANSLATION_SHEET_ID: ${{ secrets.TRANSLATION_SHEET_ID }}
run: pnpm sync-translations
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain src/lib/i18n/locales/) ]]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: sync translations from Google Sheets"
title: "chore: sync translations from Google Sheets"
body: "Automated translation sync from Google Sheets"
branch: chore/sync-translations
delete-branch: true
add-paths: |
src/lib/i18n/locales/