-
Notifications
You must be signed in to change notification settings - Fork 14
/
action.yml
92 lines (84 loc) · 3.42 KB
/
action.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
name: Sync Translations with CloudFlare
description: Sync Crowdin translations of desired environment with cloudflare
inputs:
PROJECT_NAME:
description: "Project name which is needed for R2 bucket folder"
required: true
PROJECT_SOURCE_DIRECTORY:
description: "Project source directory"
default: "./src"
required: false
CROWDIN_BRANCH_NAME:
description: "Running on production, test or staging etc"
default: "crowdin"
requried: false
CROWDIN_PROJECT_ID:
description: "Crowdin project ID which can be found in the crowdin project settings"
required: true
CROWDIN_PERSONAL_TOKEN:
description: "Crowdin personal token which can be found in the crowdin account settings"
required: true
CROWDIN_BASE_URL:
description: "Base URL of the crowdin project"
default: "https://api.crowdin.com"
required: false
CROWDIN_BASE_PATH:
description: "Crowdin personal token which can be found in the crowdin account settings"
default: "."
required: false
R2_ACCOUNT_ID:
description: "R2 account ID from the Cloudflare R2 dashboard"
required: true
R2_ACCESS_KEY_ID:
description: "R2 access key ID from the Cloudflare R2 dashboard"
required: true
R2_SECRET_ACCESS_KEY:
description: "R2 secret access key from the Cloudflare R2 dashboard"
required: true
R2_BUCKET_NAME:
description: "R2 bucket name from the Cloudflare R2 dashboard"
required: true
runs:
using: composite
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install dependencies
shell: bash
run: npm i @deriv-com/translations@latest
- name: Run extract script
shell: bash
env:
PROJECT_SOURCE_DIRECTORY: ${{ inputs.PROJECT_SOURCE_DIRECTORY }}
run: npx deriv-extract-translations $PROJECT_SOURCE_DIRECTORY --verbose
- name: Setup crowdin config
shell: bash
run: |
echo -e "project_id_env: \"CROWDIN_PROJECT_ID\"\napi_token_env: \"CROWDIN_PERSONAL_TOKEN\"\nbase_path_env: \"CROWDIN_BASE_PATH\"\nbase_url_env: \"CROWDIN_BASE_URL\"\n\npreserve_hierarchy: true\n\nfiles:\n - source: /crowdin/messages.json\n translation: /translations/%two_letters_code%.json\n languages_mapping:\n two_letters_code:\n zh-CN: zh_cn\n zh-TW: zh_tw" > crowdin.yml
- name: Crowdin pull action to download translations
uses: crowdin/github-action@v1
with:
upload_sources: true
upload_translations: false
download_translations: true
create_pull_request: false
push_translations: false
crowdin_branch_name: ${{ inputs.CROWDIN_BRANCH_NAME }}
env:
CROWDIN_PROJECT_ID: ${{ inputs.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ inputs.CROWDIN_PERSONAL_TOKEN }}
CROWDIN_BASE_URL: ${{ inputs.CROWDIN_BASE_URL }}
CROWDIN_BASE_PATH: ${{ inputs.CROWDIN_BASE_PATH }}
- name: R2 Upload Action to upload translations to Cloudflare
uses: ryand56/r2-upload-action@latest
with:
r2-account-id: ${{ inputs.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ inputs.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ inputs.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ inputs.R2_BUCKET_NAME }}
source-dir: translations
destination-dir: ./${{ inputs.PROJECT_NAME }}/${{ inputs.CROWDIN_BRANCH_NAME }}/translations