forked from mozilla-mobile/firefox-android
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (77 loc) · 2.96 KB
/
import-l10n.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# 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 0 * * *"
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 fenix
run: >
python l10n/.github/scripts/import_strings.py l10n
--toml l10n/mozilla-mobile/fenix/l10n.toml
--dest source/fenix
- 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 "[email protected]"
git checkout -B "$branch"
git add .
git commit -m "Import translations from android-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 }}