This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
86 lines (81 loc) · 4.14 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
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
name: Push Translation
permissions:
actions: write
checks: write
contents: write
deployments: write
pull-requests: write
statuses: write
on:
workflow_run:
workflows: ["Pre-push Translation"]
types:
- completed
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
jobs:
push-translation:
if: |
(startsWith(github.event.workflow_run.head_branch, 'translation') || startsWith(github.event.workflow_run.head_branch, 'stp')) &&
!contains(github.event.workflow_run.head_branch, '!') &&
!contains(github.event.workflow_run.head_branch, '@') &&
!contains(github.event.workflow_run.head_branch, '#') &&
!contains(github.event.workflow_run.head_branch, '$') &&
!contains(github.event.workflow_run.head_branch, '%') &&
!contains(github.event.workflow_run.head_branch, '^') &&
!contains(github.event.workflow_run.head_branch, '&') &&
!contains(github.event.workflow_run.head_branch, '*') &&
!contains(github.event.workflow_run.head_branch, '(') &&
!contains(github.event.workflow_run.head_branch, ')')
runs-on: ubuntu-latest
steps:
- name: 'Source: [${{github.event.workflow_run.head_repository.full_name}}/${{ github.event.workflow_run.head_branch }}]'
run: |
CLEAN_BRANCH="${BRANCH//[^[:alnum:]-_]/}"
echo "Pushing strings and translations from ${{github.event.workflow_run.head_repository.full_name}}/$CLEAN_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: '18.x'
- name: Installing Crowdin
run: npm i -g @crowdin/[email protected]
- name: Download New Translations ⬇️
if: github.event.workflow_run.head_commit.message == 'auto-pull-translation'
run: |
CLEAN_BRANCH="${BRANCH//[^[:alnum:]-_]/}"
crowdin download -b $CLEAN_BRANCH -T ${{ secrets.CROWDIN_API_KEY }} && crowdin download -b $CLEAN_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 $CLEAN_BRANCH
fi
- name: Pushing Strings & Translations ⬆️
run: |
CLEAN_BRANCH="${BRANCH//[^[:alnum:]-_]/}"
crowdin upload sources -b $CLEAN_BRANCH -T ${{ secrets.CROWDIN_API_KEY }}; crowdin upload translations -b $CLEAN_BRANCH -T ${{ secrets.CROWDIN_API_KEY }}
- 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 }} (https://crowdin.com/project/deriv-com/content/files) *`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TRANSLATION }}