Skip to content

Commit

Permalink
Bug 1813157 - Use the new l10n import action for the monorepo
Browse files Browse the repository at this point in the history
Co-authored-by: "Francesco Lodolo (:flod)" <flodolo@mozilla.com>
  • Loading branch information
2 people authored and mergify[bot] committed Jan 30, 2023
1 parent c5d3fbe commit adc5e9c
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/import-l10n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/

name: Import l10n translations

permissions:
contents: write
pull-requests: write

on:
schedule:
- cron: "0 20 * * *"
workflow_dispatch:

jobs:
copy:
name: Import strings
runs-on: ubuntu-latest
steps:
- name: Checkout Main Branch
uses: actions/checkout@v3
with:
path: "source"
ref: main
- name: Clone android-l10n repository
uses: actions/checkout@v3
with:
repository: "mozilla-l10n/android-l10n"
path: "l10n"
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python dependencies
run: |
pip install -r l10n/.github/requirements.txt
- name: Copy translated files for android-components
run: >
python l10n/.github/scripts/import_strings.py l10n
--toml l10n/mozilla-mobile/android-components/l10n.toml
--dest source/android-components
- name: Copy translated files for focus-android
run: >
python l10n/.github/scripts/import_strings.py l10n
--toml l10n/mozilla-mobile/focus-android/l10n.toml
--dest source/focus-android
- name: Commit changes and open pull request
run: |
# Only try to commit if there are pending changes
cd source
if [[ $(git diff --exit-code) || $(git ls-files --other --exclude-standard) ]]
then
branch="automation/import-l10n"
git config user.name "github-actions"
git config user.email "github-actions@users.noreply.github.com"
git checkout -B "$branch"
git add .
git commit -m "Import l10n."
git push -f origin "$branch"
# Create pull request if there isn't one open yet, use the last
# commit message as title.
open_prs=$(gh pr list --repo "$GITHUB_REPOSITORY" --json headRefName | jq --arg BRANCH "$branch" 'map(select(.headRefName==$BRANCH)) | length')
if (( $open_prs > 0 )); then
echo "Existing pull request updated."
pr_link=$(gh pr list --repo "$GITHUB_REPOSITORY" --json headRefName,url | jq -r --arg BRANCH "$branch" 'map(select(.headRefName==$BRANCH)) | .[].url')
echo "Link: $pr_link"
else
echo "Opening new pull request."
gh pr create --fill
fi
else
echo "No changes found."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit adc5e9c

Please sign in to comment.