Fetch latest strings from the l10n repo #1158
This file contains hidden or 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: Fetch latest strings from the l10n repo | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: 'recursive' | |
| token: ${{ secrets.L10N_UPDATE_TOKEN }} | |
| - name: Pull & update submodules recursively | |
| run: | | |
| git submodule update --init --recursive | |
| git submodule update --recursive --remote | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if [[ -n $(git status --porcelain) ]]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check_changes.outputs.has_changes == 'true' | |
| id: create_pr | |
| run: | | |
| # Configure git | |
| git config user.name "GitHub Actions — l10n sync" | |
| git config user.email "[email protected]" | |
| # Create a new branch | |
| BRANCH_NAME="automated-l10n-sync-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -b "$BRANCH_NAME" | |
| # Commit changes | |
| git add --all | |
| git commit -m "Merge in latest l10n strings" | |
| # Push branch | |
| git push origin "$BRANCH_NAME" | |
| # Create PR using gh CLI | |
| PR_URL=$(gh pr create \ | |
| --title "chore: Merge in latest l10n strings" \ | |
| --body "Automated pull request to sync the latest localization strings from the l10n repository." \ | |
| --base main \ | |
| --head "$BRANCH_NAME") | |
| # Extract PR number from URL | |
| PR_NUMBER=$(echo "$PR_URL" | grep -oP '\d+$') | |
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.L10N_UPDATE_TOKEN }} | |
| - name: Enable auto-merge | |
| if: steps.check_changes.outputs.has_changes == 'true' && steps.create_pr.outputs.pr_number | |
| run: gh pr merge ${{ steps.create_pr.outputs.pr_number }} --auto --merge | |
| env: | |
| GH_TOKEN: ${{ secrets.L10N_UPDATE_TOKEN }} |