Import Android components #743
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: Import Android components | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
copy: | |
name: Import strings | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone android-l10n repository | |
uses: actions/checkout@v3 | |
with: | |
path: "l10n" | |
- name: Clone main code repository | |
uses: actions/checkout@v3 | |
with: | |
repository: "mozilla-mobile/firefox-android" | |
path: "source" | |
- 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 source files | |
run: > | |
python l10n/.github/scripts/import_strings.py source | |
--toml source/android-components/l10n.toml | |
--dest l10n/mozilla-mobile/android-components | |
- name: Commit changes and open pull request | |
run: | | |
# Only try to commit if there are pending changes | |
cd l10n | |
if [[ $(git diff --exit-code) || $(git ls-files --other --exclude-standard) ]] | |
then | |
branch="ac_l10n_updates" | |
git config user.name "l10n-bot" | |
git config user.email "[email protected]" | |
git checkout -B "$branch" | |
git add . | |
git commit -m "Import android-components quarantine" | |
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 --label l10n-bot | |
fi | |
else | |
echo "No changes found." | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.ANDROID_GITHUB_TOKEN }} |