Translated using Weblate (Portuguese (Brazil)) #1111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update localization | |
on: [push] | |
jobs: | |
pull-localization: | |
name: Pull localization from Weblate | |
# Only run this for pushes from Weblate | |
# Note, this is not a secure check as git author can be changed easily | |
#if: github.event.head_commit.committer.email == '[email protected]' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the weblate-localization branch | |
uses: actions/checkout@v4 | |
- name: Checkout the source branch | |
uses: actions/checkout@v4 | |
with: | |
path: specify7 | |
# Assumes the strings originally came from production branch | |
ref: production | |
fetch-depth: 0 | |
# Using a Personal Access Token from an admin account to bypass branch | |
# protection rules and allow direct pushes to production. Inspirited | |
# by: https://github.com/community/community/discussions/13836 | |
token: ${{ secrets.WEBLATE_PUSH_TO_GITHUB }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: specify7/specifyweb/frontend/js_src/package.json | |
cache: "npm" | |
cache-dependency-path: specify7/specifyweb/frontend/js_src/package-lock.json | |
- name: Install Dependencies | |
working-directory: specify7/specifyweb/frontend/js_src | |
run: npm ci | |
- name: Integrate modified strings back into code | |
working-directory: specify7/specifyweb/frontend/js_src | |
env: | |
WEBLATE_API_TOKEN: ${{ secrets.WEBLATE_API_TOKEN }} | |
run: | | |
npm run pullFromWeblate -- --directory ../../../../strings | |
- name: Commit updated localization strings | |
working-directory: specify7 | |
run: | | |
git add . | |
if git diff-index --quiet HEAD --; then | |
echo "Localization strings are unchanged" | |
else | |
# Set the committer and author to the name and email of the person | |
# who triggered the action (Weblate will commit on behalf of the | |
# person who did the localization) | |
git config --local user.name "Hosted Weblate" | |
git config --local user.email "[email protected]" | |
git commit \ | |
--author '${{ github.event.head_commit.author.name }} <${{ github.event.head_commit.author.email }}>' \ | |
-m 'Sync localization strings with Weblate' \ | |
-m "Triggered by ${{ github.sha }} on branch ${{ github.ref }}" | |
git push | |
fi |