-
-
Notifications
You must be signed in to change notification settings - Fork 643
84 lines (73 loc) · 2.61 KB
/
regenerate_english_userDocs_translation_source.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
name: Update User Documentation
on:
push:
branches:
- beta
- xliff # Must be removed before merge
paths:
- 'user_docs/en/userGuide.md'
jobs:
update-documentation:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install lxml requests
- name: Identify changed files
id: identify_changes
shell: pwsh
run: |
$changedFiles = @()
if (git diff --name-only HEAD~1 HEAD | Select-String -Pattern '^user_docs/en/userGuide.md') {
$changedFiles += 'userGuide.md'
}
if (git diff --name-only HEAD~1 HEAD | Select-String -Pattern '^user_docs/en/changes.md') {
$changedFiles += 'changes.md'
}
$changedFiles | Out-File -FilePath changed_files.txt
- name: Process each changed file
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$changedFiles = Get-Content changed_files.txt
foreach ($file in $changedFiles) {
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($file)
$xliff = "user_docs/en/$baseName.xliff"
$tempXliff = "user_docs/en/$baseName.xliff.temp"
$markdown = "user_docs/en/$file"
# Update the xliff file with the changes from the new markdown file
# Keeping existing translation IDs in tact
python user_docs/markdownTranslate.py updateXliff -x $xliff -m $markdown -o $tempXliff
move-item -Path $tempXliff -Destination $xliff -Force
}
- name: Crowdin upload
env:
crowdinProjectID: ${{ vars.CROWDIN_PROJECT_ID }}
crowdinAuthToken: ${{ secrets.CROWDIN_AUTH_TOKEN }}
run: |
python appVeyor/crowdinSync.py uploadSourceFile 18 user_docs/en/userguide.xliff
- name: Commit changes
run: |
$ErrorActionPreference = 'Stop'
git config --local user.name "GitHub Actions"
git config --local user.email "[email protected]"
git add user_docs/en/*.xliff
git commit -m "Update user documentation files"
if: success()
- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$ErrorActionPreference = 'Stop'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
git push origin HEAD
if: success()