forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (114 loc) Β· 5.38 KB
/
translation-sync.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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 }}