Skip to content

Commit 71d11f6

Browse files
authored
feat: workflow and script for text (#19)
* feat: workflow and script for text * chore: test run locally
1 parent ead9117 commit 71d11f6

8 files changed

Lines changed: 1129 additions & 268 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Sync Translations from Google Sheets
2+
3+
on:
4+
repository_dispatch:
5+
types: [sync-translations]
6+
workflow_dispatch: # Allow manual triggering from GitHub UI
7+
8+
jobs:
9+
sync:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v3
24+
with:
25+
version: '10.7.1'
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
31+
32+
- uses: actions/cache@v4
33+
name: Setup pnpm cache
34+
with:
35+
path: ${{ env.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
39+
40+
- name: Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
43+
- name: Sync translations from Google Sheets
44+
env:
45+
GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
46+
TRANSLATION_SHEET_ID: ${{ secrets.TRANSLATION_SHEET_ID }}
47+
run: pnpm sync-translations
48+
49+
- name: Check for changes
50+
id: check_changes
51+
run: |
52+
if [[ -n $(git status --porcelain src/lib/i18n/locales/) ]]; then
53+
echo "has_changes=true" >> $GITHUB_OUTPUT
54+
else
55+
echo "has_changes=false" >> $GITHUB_OUTPUT
56+
fi
57+
58+
- name: Commit and push changes
59+
if: steps.check_changes.outputs.has_changes == 'true'
60+
run: |
61+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
62+
git config --local user.name "github-actions[bot]"
63+
git add src/lib/i18n/locales/
64+
git commit -m "chore: sync translations from Google Sheets"
65+
git push
66+

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1212
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1313
"format": "prettier --write \"src/**/*.{js,ts,svelte,css,html}\"",
14-
"format:check": "prettier --check \"src/**/*.{js,ts,svelte,css,html}\""
14+
"format:check": "prettier --check \"src/**/*.{js,ts,svelte,css,html}\"",
15+
"sync-translations": "tsx scripts/sync-translations.ts"
1516
},
1617
"devDependencies": {
1718
"@skeletonlabs/skeleton": "^3.1.3",
19+
"googleapis": "^144.0.0",
20+
"tsx": "^4.19.0",
1821
"@skeletonlabs/skeleton-svelte": "^1.2.3",
1922
"@sveltejs/adapter-vercel": "^5.8.1",
2023
"@sveltejs/kit": "^2.22.2",

0 commit comments

Comments
 (0)