-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflows of integrate with crowdin (#2146)
- Loading branch information
Showing
5 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Crowdin PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
export_only_approved: | ||
description: "Include approved translations only in exported files. If not combined with --skip-untranslated-strings option, strings without approval are fulfilled with the source language" | ||
default: false | ||
type: boolean | ||
required: false | ||
schedule: | ||
- cron: "0 0 * * *" # Every day 0 o'clock | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: read | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pull: | ||
name: Synchronize with Crowdin | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 1 # Should be 1 to avoid parallel builds | ||
matrix: | ||
lc: [ko, pt-BR, ru, th, zh-CN, zh-TW] # Target languages https://developer.crowdin.com/language-codes/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get BOT token | ||
id: get_bot_token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.GH_APP_ID }} | ||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
owner: ${{ github.repository_owner }} | ||
repositories: "site" | ||
|
||
- name: Download Translations && Create PR | ||
uses: crowdin/github-action@v2 | ||
with: | ||
upload_sources: false | ||
push_sources: false | ||
|
||
upload_translations: false | ||
push_translations: true | ||
download_translations: true | ||
create_pull_request: true | ||
|
||
export_only_approved: ${{ inputs.export_only_approved || false }} | ||
commit_message: "l10n(${{ matrix.lc }}): New translations from Crowdin" | ||
localization_branch_name: l10n_${{ github.ref_name }}_${{ matrix.lc }} | ||
pull_request_base_branch_name: ${{ github.ref_name }} | ||
pull_request_title: "l10n(${{ matrix.lc }}): New translations from Crowdin" | ||
pull_request_labels: "crowdin" | ||
download_language: ${{ matrix.lc }} | ||
skip_ref_checkout: false | ||
github_user_name: "hexo-crowdin[bot]" | ||
github_user_email: "159447924+hexo-crowdin[bot]@users.noreply.github.com" | ||
|
||
crowdin_branch_name: ${{ github.ref_name }} | ||
config: "crowdin.yml" | ||
env: | ||
GITHUB_TOKEN: ${{ steps.get_bot_token.outputs.token }} | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Crowdin Upload Translations | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
auto_approve_imported: | ||
description: "Automatically approves uploaded translations" | ||
default: false | ||
type: boolean | ||
required: false | ||
import_eq_suggestions: | ||
description: "Defines whether to add translation if it is equal to source string in Crowdin project" | ||
default: false | ||
type: boolean | ||
required: false | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
upload-translation: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 1 # Should be 1 to avoid parallel builds | ||
matrix: | ||
lc: [ko, pt-BR, ru, th, zh-CN, zh-TW] # Target languages https://developer.crowdin.com/language-codes/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: crowdin/github-action@v2 | ||
with: | ||
upload_sources: false | ||
push_sources: false | ||
|
||
upload_translations: true | ||
push_translations: false | ||
download_translations: false | ||
create_pull_request: false | ||
|
||
upload_language: ${{ matrix.lc }} | ||
auto_approve_imported: ${{ inputs.auto_approve_imported || false }} | ||
import_eq_suggestions: ${{ inputs.import_eq_suggestions || false }} | ||
|
||
crowdin_branch_name: ${{ github.ref_name }} | ||
config: "crowdin.yml" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Crowdin Upload Sources | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
push: | ||
branches: | ||
- "master" | ||
paths: | ||
- "source/about/*.md" | ||
- "source/api/*.md" | ||
- "source/docs/*.md" | ||
- "source/*.md" | ||
- ".github/workflows/crowdin-upload.yml" | ||
- "./crowdin.yml" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
upload-source: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 1 # Should be 1 to avoid parallel builds | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: crowdin/github-action@v2 | ||
with: | ||
upload_sources: true | ||
push_sources: false | ||
|
||
upload_translations: false | ||
push_translations: false | ||
download_translations: false | ||
create_pull_request: false | ||
|
||
crowdin_branch_name: ${{ github.ref_name }} | ||
config: "crowdin.yml" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
project_id_env: CROWDIN_PROJECT_ID | ||
api_token_env: CROWDIN_PERSONAL_TOKEN | ||
base_path: "." | ||
base_url: "https://api.crowdin.com" | ||
preserve_hierarchy: true | ||
commit_message: "l10n(%two_letters_code%): New translations `%original_file_name%` from Crowdin" | ||
append_commit_message: false | ||
pull_request_title: "l10n: New Crowdin updates" | ||
pull_request_labels": | ||
- "crowdin" | ||
- "l10n" | ||
|
||
languages_mapping: &languages_mapping | ||
two_letters_code: | ||
zh-CN: zh-cn | ||
zh-TW: zh-tw | ||
pt-BR: pt-br | ||
|
||
files: | ||
- source: "source/api/*.md" | ||
translation: "/source/%two_letters_code%/api/%original_file_name%" | ||
update_option: update_as_unapproved | ||
type: fm_md | ||
languages_mapping: *languages_mapping | ||
|
||
- source: "source/docs/*.md" | ||
translation: "/source/%two_letters_code%/docs/%original_file_name%" | ||
update_option: update_as_unapproved | ||
type: fm_md | ||
languages_mapping: *languages_mapping | ||
|
||
- source: "source/*.md" | ||
translation: "/source/%two_letters_code%/%original_file_name%" | ||
update_option: update_as_unapproved | ||
type: fm_md | ||
languages_mapping: *languages_mapping |