forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (57 loc) · 3.15 KB
/
translation-push.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
name: Push Translation
on:
workflow_run:
workflows: ["Pre-push Translation"]
types:
- completed
jobs:
push-translation:
if: startsWith(github.event.workflow_run.head_branch, 'translation') || startsWith(github.event.workflow_run.head_branch, 'stp')
runs-on: ubuntu-latest
steps:
- name: 'Source: [${{github.event.workflow_run.head_repository.full_name}}/${{ github.event.workflow_run.head_branch }}]'
run: echo 'Pushing strings and translations from ${{github.event.workflow_run.head_repository.full_name}}/${{ github.event.workflow_run.head_branch }}'
- name: Checkout 🛎️
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_branch }}
repository: ${{github.event.workflow_run.head_repository.full_name}}
- name: Setup Node
uses: actions/[email protected]
with:
node-version: '14.x'
- name: Installing Crowdin
run: npm i -g @crowdin/cli
- name: Pushing Strings & Translations ⬆️
run:
crowdin upload sources -b ${{ github.event.workflow_run.head_branch }} -T ${{ secrets.CROWDIN_API_KEY }}; crowdin upload translations -b ${{ github.event.workflow_run.head_branch }} -T ${{ secrets.CROWDIN_API_KEY }}
- name: Download New Translations ⬇️
if: github.event.workflow_run.head_commit.message == 'auto-pull-translation'
run: |
crowdin download -b ${{ github.event.workflow_run.head_branch }} -T ${{ secrets.CROWDIN_API_KEY }} && crowdin download -b ${{ github.event.workflow_run.head_branch }} -l zh-CN -T ${{ secrets.CROWDIN_API_KEY }}
if git diff --exit-code; then
echo "No new translation data to commit"
else
echo "Committing new translation data 📝"
echo "Setting up Git identity"
git config --global user.name "DerivFE"
git config --global user.email "[email protected]"
git add -u
git commit -m "translation: 📚 sync translations from crowdin feature branch"
git push origin ${{ github.event.workflow_run.head_branch }}
fi
- name: Slack Notification 📣
uses: 8398a7/action-slack@v3
with:
status: custom
fields: workflow,job,commit,repo
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `*[Deriv.com]* New strings are ready for translation and uploaded on crowdin branch: *${{ github.event.workflow_run.head_branch }} *`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TRANSLATION }}