Sync from main to locale branches #28
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
# 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: Sync from main to locale branches | |
on: | |
schedule: | |
- cron: "0 4 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- run: sudo apt-get install -y git-filter-repo | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: git config | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- id: changed-locales | |
run: echo "LIST=$(git diff-tree --no-commit-id --name-only last-sync main | grep -E '^[a-z]{2,3}(-|$)' | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
- run: | | |
for lc in ${{ steps.changed-locales.outputs.LIST }}; do | |
git tag base-$lc last-sync; | |
git branch next-$lc main; | |
git filter-repo --subdirectory-filter $lc --force --refs next-$lc base-$lc; | |
git checkout --track origin/$lc; | |
git cherry-pick base-$lc..next-$lc; | |
done | |
shell: bash | |
- run: git push origin ${{ steps.changed-locales.outputs.LIST }} | |
shell: bash | |
- run: git tag --force last-sync main | |
- run: git push --force origin last-sync |