Skip to content

User docs github action: for now only handle user guide, not changes … #26

User docs github action: for now only handle user guide, not changes …

User docs github action: for now only handle user guide, not changes … #26

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()