|
| 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 | +
|
0 commit comments