Windows 8 compatibility: Several Exceptions #82
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: Sync translations with Crowdin (two-way) | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- '**/Resources*.resx' | |
- '.github/workflows/crowdin_sync.yml' | |
issue_comment: | |
types: [created] | |
workflow_dispatch: | |
env: | |
# The git branch used for sync with crowdin and for the pull request | |
BRANCH: crowdin | |
# crowdin config | |
CONFIG: '.github/.crowdin.yml' | |
PROJECT: ${{ secrets.CROWDIN_PROJECT_ID }} | |
TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | |
concurrency: | |
group: ${{ github.workflow }} | |
jobs: | |
sync: | |
name: Sync translations with crowdin | |
runs-on: ubuntu-latest | |
if: | | |
github.event_name != 'issue_comment' || ( | |
contains(github.event.issue.labels.*.name, 'translation') && | |
contains(github.event.comment.body, '/sync') | |
) | |
steps: | |
- name: Install crowdin cli | |
run: | | |
wget https://artifacts.crowdin.com/repo/deb/crowdin3.deb -O crowdin.deb --no-verbose | |
sudo dpkg -i crowdin.deb | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup crowdin branch | |
run: | | |
ARGS="--base-path=. --config=$CONFIG --project-id=$PROJECT --token=$TOKEN --no-progress" | |
REF=$(basename $GITHUB_REF) | |
crowdin branch add $REF $ARGS | |
ARGS="--branch=$REF $ARGS" | |
echo "ARGS=$ARGS" >> $GITHUB_ENV | |
# Merge changes from git and crowdin and sync back to crowdin | |
############################################################## | |
- name: Prepare git branch for merge | |
run: | | |
git config user.name "Bot" | |
git config user.email "<>" | |
git checkout $BRANCH 2>/dev/null || git checkout -b $BRANCH $GITHUB_REF | |
- name: Download changes from crowdin | |
run: | | |
crowdin download sources $ARGS | |
crowdin download $ARGS | |
git status -s | |
git diff | |
git add . | |
git commit -m "Update from crowdin" || true | |
- name: Merge and resolve conflicts | |
run: | | |
git merge $GITHUB_REF -Xtheirs -v | |
git diff HEAD~1.. | |
- name: Upload to crowdin | |
run: | | |
crowdin upload sources --delete-obsolete $ARGS | |
crowdin upload translations --import-eq-suggestions $ARGS | |
# Note: Without the "import-eq-suggestions" switch, new translations that literally match the source string | |
# would not be uploaded, so a PR would be opened during back-sync to remove these (redundant) translations. | |
# Create or update the pull request with data from crowdin | |
########################################################### | |
- name: Clean git branch | |
run: | | |
git checkout -B $BRANCH $GITHUB_REF | |
git checkout $(basename $GITHUB_REF) | |
- name: Download from crowdin | |
run: | | |
crowdin download sources $ARGS | |
crowdin download $ARGS | |
git status -s | |
git diff | |
- name: Collect statistics | |
run: | | |
echo 'INFO<<EOF' >> $GITHUB_ENV | |
crowdin status -v $ARGS >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Create Pull Request | |
uses: peter-evans/[email protected] | |
with: | |
branch: ${{ env.BRANCH }} | |
commit-message: Update from crowdin | |
title: Translation updates from Crowdin | |
labels: | | |
translation | |
body: | | |
Updates translations from [Crowdin project](https://crowdin.com/project/PasteIntoFile) | |
``` | |
${{ env.INFO }} | |
``` | |
To re-sync and update this PR include /sync in a comment. | |
*Do not delete the branch after merging! It is required to correctly merge future changes from GitHub and Crowdin without overwriting either.* | |