-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First attempt at actual localization imports action
- Loading branch information
Showing
1 changed file
with
82 additions
and
16 deletions.
There are no files selected for viewing
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
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 }} |