Create a PR with changes after importing strings #36
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: Create a PR with changes after importing strings | |
on: | |
schedule: | |
- cron: '0 11 * * 1' | |
workflow_dispatch: | |
inputs: | |
branchName: | |
description: 'Branch used as target for automation' | |
required: true | |
default: 'main' | |
jobs: | |
build: | |
runs-on: macos-13 | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: [3.9] | |
xcode: ["14.3.1"] | |
steps: | |
- 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: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- 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=Localize [ver] String import $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=Localize [$version] String import $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: sh ./bootstrap.sh --importLocales | |
- name: Update new strings | |
run: |- | |
git diff || (git add firefox-ios/Shared/*/*.lproj/* firefox-ios/Shared/*.lproj/* firefox-ios/WidgetKit/*.lproj/* firefox-ios/Client/*/*.lproj/* firefox-ios/Client/*.lproj/*) | |
git restore firefox-ios/Client.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
committer: GitHub <noreply@github.com> | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: ${{ env.pr_title }} | |
title: ${{ env.pr_title }} | |
branch: ${{ env.branch_name }} | |
body: ${{ env.pr_body }} |