-
Notifications
You must be signed in to change notification settings - Fork 107
87 lines (81 loc) · 3.09 KB
/
check_l10n.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 }}