This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
chore: empty (#7802) #1813
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 Master Translation | |
permissions: | |
actions: write | |
checks: write | |
contents: write | |
deployments: write | |
pull-requests: write | |
statuses: write | |
on: | |
push: | |
branches: | |
- 'master*' | |
jobs: | |
sync-translation: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Branch Name | |
run: | | |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/new_translation_strings" ]; then | |
echo "The branch recently merged to master is the branch came from this workflow, skipping further steps." | |
exit 0 | |
fi | |
- name: Checkout ποΈ | |
uses: actions/[email protected] | |
- name: Setup Node | |
uses: actions/[email protected] | |
with: | |
node-version: '18.x' | |
- run: npm i -g @crowdin/[email protected] | |
- name: Fetch,Sync & Push Strings to Crowdin | |
id: sync_translations | |
run: | | |
branch_name="new_translation_strings" | |
echo "Setting up Git identity" | |
git config --global user.name "DerivFE" | |
git config --global user.email "[email protected]" | |
echo "Checking out new branch [$branch_name]" | |
git checkout -b "$branch_name" | |
# Download new translated strings | |
echo 'Fetch Crowdin Master Translation β¬οΈ' | |
crowdin download -b master -T ${{ secrets.CROWDIN_API_KEY }} && crowdin download -b master -l zh-CN -T ${{ secrets.CROWDIN_API_KEY }} | |
if [ -n "$(git status --porcelain)" ]; then | |
# New strings are added, create a PR to update the master | |
# Commit the newly downloaded files | |
cd $(git rev-parse --show-toplevel) | |
git add . | |
git commit -m "translations: π sync translations with crowdin" | |
# Force push to this branch in case a previous run created it. | |
git push --set-upstream origin "$branch_name" -f | |
sudo apt install gh | |
gh auth login --with-token <<< ${{ github.token }} | |
gh pr close "$branch_name" || true | |
pr_output=$(gh pr create --base "master" --title "[translations] New strings from crowdin π" --head "binary-com:$branch_name" -F ".github/translation_sync_template.md") | |
echo "PR_URL=$pr_output" >> $GITHUB_ENV | |
fi | |
# Upload new strings to Crowdin | |
crowdin upload sources -b master -T ${{ secrets.CROWDIN_API_KEY }}; crowdin upload translations -b master -T ${{ secrets.CROWDIN_API_KEY }} | |
- name: Slack Notification π£ | |
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 | |
with: | |
status: custom | |
fields: workflow,job,commit,repo | |
custom_payload: | | |
{ | |
attachments: [{ | |
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning', | |
text: `*[Deriv.com]* strings are synced to crowdin master branch:(https://crowdin.com/project/deriv-com/content/files)` | |
}] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TRANSLATION }} | |
- name: Slack Notification for Release Managers π£ | |
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 | |
with: | |
status: custom | |
fields: workflow,job,commit,repo | |
custom_payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "context", | |
"elements": [ | |
{ | |
"type": "plain_text", | |
"text": ":robot_face: Translation Pull Request Notification", | |
"emoji": true | |
} | |
] | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Hey there π *<!subteam^S058V0ZJ16X>*, translation in deriv.com just got synchronized from `crowdin`, please help merging the PR to keep deriv.com up to date." | |
}, | |
"accessory": { | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": "View", | |
"emoji": true | |
}, | |
"value": "View PR", | |
"url": "${{ env.PR_URL }}", | |
"action_id": "button-action" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TRANSLATION_PR }} | |