Skip to content

Download translations and upload new strings #10

Download translations and upload new strings

Download translations and upload new strings #10

name: Download translations and upload new strings
on:
schedule:
# 4am UTC
- cron: "0 4 * * *"
workflow_dispatch:
jobs:
download-translations-and-upload-new-strings:
runs-on: ubuntu-latest
steps:
- 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:
ssh-key: ${{ secrets.STRING_IMPORT_DEPLOY_KEY }}
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: Check mergefreeze status
id: mergefreeze
shell: bash # Enable pipefail
run: |
echo frozen=$(curl "https://www.mergefreeze.com/api/branches/actualbudget/actual/master?access_token=${{ secrets.MERGEFREEZE_API_KEY }}" | jq -r .frozen) > $GITHUB_OUTPUT
- name: Pull latest translations
working-directory: actual
if: ${{ steps.mergefreeze.frozen == 'false' }}
run: |
# Not using git subtree to avoid merge commits
cp -r ../translations/*.json packages/desktop-client/locale/
git add .
if git commit -m "Update translations"; then
git push
else
echo "No changes to commit"
fi
- 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
if: always() # Clean up even on failure
run: |
wlc \
--url https://hosted.weblate.org/api/ \
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \
unlock \
actualbudget/actual