HTP; common_voice_privacy_notice.md/common_voice_terms.md (#2158) #408
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: Update L10n Tracking Branch | |
on: | |
# Triggers the workflow on push events only for the default branch | |
push: | |
branches: | |
- main | |
paths: | |
- '**.md' | |
- '**.json' | |
- '.github/workflows/check_l10n.yml' | |
# Ignore Markdown files in the root | |
- '!*.md' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
fetch: | |
name: L10n automation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Linux packages | |
run: | | |
sudo apt update | |
sudo apt install git hub -y | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
path: "clone" | |
fetch-depth: 0 | |
- name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Set up git credentials | |
run : | | |
git config --global user.email '[email protected]' | |
git config --global user.name 'Francesco Lodolo [:flod]' | |
- name: Update l10n files in repository | |
run: | | |
cd clone | |
# Store stats on files | |
python .github/scripts/check_status.py | |
# Only keep source files that are relevant for translation | |
python .github/scripts/cleanup_repository.py | |
# Generate HTML summary | |
python .github/scripts/generate_summary.py | |
# Use temporary folder to store files from the default branch | |
cd ..;mkdir temp_files | |
# Copy files, excluding scripts and workflows | |
# Use --ignore-times (-I) options to ensure all files are copied | |
rsync -aIv --exclude={".git",".gitignore",".github/CODEOWNERS",".github/scripts",".github/templates",".github/workflows",".github/requirements.txt",".vscode","package.json"} clone/ temp_files/ | |
# Use l10n_reference as a base for l10n_updates, to avoid generating | |
# a huge diff in the pull request. | |
cd clone | |
git reset --hard origin/l10n_reference | |
git checkout -B l10n_updates | |
# Restore files from the default branch | |
# Use --ignore-times (-I) options to ensure all files are copied | |
rsync -aIv ../temp_files/ ./ | |
- name: Commit changes to l10n_updates branch | |
continue-on-error: true | |
run: | | |
# Commit changes. Failure is allowed if there is nothing to commit. | |
cd clone | |
git add . | |
git commit -m "Update documents relevant for l10n" | |
git push -f origin l10n_updates | |
- name: Open pull request | |
continue-on-error: true | |
run: | | |
# continue-on-error is needed in case there is already an open PR | |
cd clone | |
changes=$(git diff --name-only origin/l10n_reference origin/l10n_updates -- | wc -l | awk '{print $1}') | |
if [[ "$changes" = "0" ]]; | |
then | |
echo "No changes." | |
else | |
# Create pull request | |
hub pull-request -m "[l10n] Source document updates" -h l10n_updates -b l10n_reference -l l10n -r @mozilla/legal-l10n | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.L10N_LEGAL }} |