Skip to content

Commit

Permalink
Update string extraction workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdoming committed Jan 4, 2025
1 parent 103710b commit 9aa9b2a
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 29 deletions.
12 changes: 10 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: Setup

inputs:
working-directory:
description: 'Working directory to run in, default .'
required: false
default: .
type: string

runs:
using: composite
steps:
Expand All @@ -15,9 +22,10 @@ runs:
uses: actions/cache@v4
id: cache
with:
path: '**/node_modules'
key: yarn-v1-${{ runner.os }}-${{ hashFiles('.nvmrc') }}-${{ hashFiles('**/yarn.lock') }}
path: ${{ format('{0}/**/node_modules', inputs.working-directory) }}
key: yarn-v1-${{ runner.os }}-${{ hashFiles(format('{0}/.nvmrc', inputs.working-directory)) }}-${{ hashFiles(format('{0}/**/yarn.lock', inputs.working-directory)) }}
- name: Install
working-directory: ${{ inputs.working-directory }}
run: yarn --immutable
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
89 changes: 62 additions & 27 deletions .github/workflows/i18n-string-extract-master.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,71 @@
name: Extract and upload i18n strings

on:
push:
branches:
- master
schedule:
# 4am UTC
- cron: "0 4 * * *"
workflow_dispatch:

jobs:
extract-and-upload-i18n-strings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/setup
- name: Configure i18n client
run: |
pip install wlc
- name: Generate i18n strings
run: yarn generate:i18n
- name: Upload i18n strings
run: |
if [[ ! -f packages/desktop-client/locale/en.json ]]; then
echo "File packages/desktop-client/locale/en.json not found. Ensure the file was generated correctly."
exit 1
fi
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
upload \
--author-name "Actual Budget" \
--author-email "[email protected]" \
--method add \
--input packages/desktop-client/locale/en.json \
actualbudget/actual/en
echo "Translations uploaded"
- name: Configure i18n client
run: |
pip install wlc
- name: Lock translations
run: |
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
lock \
actualbudget/actual
- name: Update VCS with latest translations
run: |
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
pull \
actualbudget/actual
- name: Check out main repository
uses: actions/checkout@v4
with:
path: actual
- name: Check out translations
uses: actions/checkout@v4
with:
repository: actualbudget/translations
path: translations
- name: Set up environment
uses: ./actual/.github/actions/setup
with:
working-directory: actual
- name: Configure Git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Generate i18n strings
working-directory: actual
run: |
yarn generate:i18n
if [[ ! -f packages/desktop-client/locale/en.json ]]; then
echo "File packages/desktop-client/locale/en.json not found. Ensure the file was generated correctly."
exit 1
fi
- name: Check in new i18n strings
working-directory: translations
run: |
cp ../actual/packages/desktop-client/locale/en.json .
git add .
if git commit -m "Update source strings"; then
git push
else
echo "No changes to commit"
fi
- name: Unlock translations
run: |
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
unlock \
actualbudget/actual

0 comments on commit 9aa9b2a

Please sign in to comment.