Skip to content

Commit

Permalink
First attempt at actual localization imports action
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhand committed Feb 17, 2025
1 parent 3ce899f commit 457b468
Showing 1 changed file with 82 additions and 16 deletions.
98 changes: 82 additions & 16 deletions .github/workflows/import-localizations.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,85 @@
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
name: "Firefox: import translations"
on:
# schedule:
# - cron: '0 11 * * 1'
workflow_dispatch:
inputs:
branchName:
description: 'Branch used as target for automation'
required: true
default: 'main'
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
build:
runs-on: macos-15
strategy:
max-parallel: 4
matrix:
xcode: ["16.2"]
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
- uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.inputs.branchName }}

- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app

- name: Get PR info
run: |
current_date=$(date +"%Y-%m-%d")
# Use 'main' when triggered via cron
current_branch=${{ github.event.inputs.branchName || 'main' }}
echo "current_date=$current_date" >> $GITHUB_ENV
if [[ $current_branch == 'main' ]]; then
echo "branch_name=string-import-$current_date" >> $GITHUB_ENV
echo "pr_title=Import localizations $current_date" >> $GITHUB_ENV
echo "pr_body=This automated PR imports string changes" >> $GITHUB_ENV
else
# version: v105.0 -> v105
version=${current_branch%??}
echo "branch_name=string-import-$current_branch-$current_date" >> $GITHUB_ENV
echo "pr_title=[$version]: Import localizations $current_date" >> $GITHUB_ENV
echo "pr_body=This automated PR imports string changes into branch '$current_branch'" >> $GITHUB_ENV
fi
- name: Run script to import strings
run: |
echo "\n\n[*] Cloning required repo to import strings"
if [ -d "LocalizationTools" ] || [ -d "giellakbd-ios-l10n" ]; then
rm -rf LocalizationTools
rm -rf giellakbd-ios-l10n
fi
git clone --depth 1 https://github.com/divvun/LocalizationTools.git || exit 1
git clone --depth 1 https://github.com/divvun/giellakbd-ios-l10n || exit 1
echo "\n\n[*] Building tools/Localizations"
(cd LocalizationTools && swift build)
echo "\n\n[*] Importing Strings - takes a minute. (output in import-strings.log)"
(cd LocalizationTools && swift run LocalizationTools \
--import \
--project-path "$PWD/../giellakbd-ios/GiellaKeyboard.xcodeproj" \
--l10n-project-path "$PWD/../giellakbd-ios-l10n") > import-strings.log 2>&1
echo "\n\n[!] Strings have been imported. You can now create a PR."
echo "\n\n[*] Clean up cloned repos"
rm -rf LocalizationTools
rm -rf giellakbd-ios-l10n
- name: Update new strings
run: |-
git diff || (git add .)
# git restore firefox-ios/Client.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: ${{ env.pr_title }}
title: "Import Localizations ${{ env.current_date }}"
branch: ${{ env.branch_name }}
body: ${{ env.pr_body }}

0 comments on commit 457b468

Please sign in to comment.