freeCodeCamp/.github/workflows/crowdin-i18n-docs-download....

180 lines
5.8 KiB
YAML

name: Crowdin Docs Download
on:
workflow_dispatch:
schedule:
# runs every day at 12:00 noon UTC
- cron: "0 12 * * *"
jobs:
i18n-download-docs-translations:
name: Docs
runs-on: ubuntu-18.04
steps:
- name: Checkout Source Files
uses: actions/checkout@v2
##### Download Chinese #####
- name: Crowdin Download Chinese Translations
uses: crowdin/github-action@master
# options: https://github.com/crowdin/github-action/blob/master/action.yml
with:
# uploads
upload_sources: false
upload_translations: false
auto_approve_imported: false
import_eq_suggestions: false
# downloads
download_translations: true
download_language: zh-CN
skip_untranslated_files: false
export_only_approved: true
push_translations: false
# pull-request
create_pull_request: false
# global options
config: './config/crowdin/docs/crowdin.yml'
base_url: ${{ secrets.CROWDIN_BASE_URL_FCC }}
# Uncomment below to debug
# dryrun_action: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_DOCS }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
##### Download Portuguese#####
- name: Crowdin Download Portuguese Translations
uses: crowdin/github-action@master
# options: https://github.com/crowdin/github-action/blob/master/action.yml
with:
# uploads
upload_sources: false
upload_translations: false
auto_approve_imported: false
import_eq_suggestions: false
# downloads
download_translations: true
download_language: pt-BR
skip_untranslated_files: false
export_only_approved: true
push_translations: false
# pull-request
create_pull_request: false
# global options
config: './config/crowdin/docs/crowdin.yml'
base_url: ${{ secrets.CROWDIN_BASE_URL_FCC }}
# Uncomment below to debug
# dryrun_action: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_DOCS }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
##### Download Espanol #####
- name: Crowdin Espanol Download Translations
uses: crowdin/github-action@master
# options: https://github.com/crowdin/github-action/blob/master/action.yml
with:
# uploads
upload_sources: false
upload_translations: false
auto_approve_imported: false
import_eq_suggestions: false
# downloads
download_translations: true
download_language: es-EM
skip_untranslated_files: false
export_only_approved: true
commit_message: 'chore(i8n,docs): processed translations'
localization_branch_name: i18n-sync-docs
push_translations: true
# pull-request
create_pull_request: false
# global options
config: './config/crowdin/docs/crowdin.yml'
base_url: ${{ secrets.CROWDIN_BASE_URL_FCC }}
# Uncomment below to debug
# dryrun_action: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_DOCS }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
# Generate PR - all languages should go ABOVE this. #
- name: Create PR
uses: actions/github-script@v3
with:
github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
script: |
const branchExists = await github.repos.getBranch({
owner: 'freeCodeCamp',
repo: 'freeCodeCamp',
branch: 'i18n-sync-docs'
}).catch(err => {
console.info("Branch does not exist. Likely no changes in download?");
});
if (!branchExists || branchExists.status !== 200) {
return;
}
const pullRequestExists = await github.pulls.list({
owner: 'freeCodeCamp',
repo: 'freeCodeCamp',
head: 'freeCodeCamp:i18n-sync-docs'
});
if (pullRequestExists.data.length) {
console.info("It looks like a pull request already exists for this branch.");
return;
}
const PR = await github.pulls.create({
owner: 'freeCodeCamp',
repo: 'freeCodeCamp',
head: 'i18n-sync-docs',
base: 'main',
title: 'chore(i18n,docs): processed translations',
body: 'This PR was opened auto-magically by Crowdin.'
}).catch(err => {
console.info("Unpredicted error occurred when trying to create the PR.");
console.error(err);
});
if (!PR || PR.status !== 201) {
return;
}
const PRNumber = PR.data.number;
await github.issues.addLabels({
owner: 'freeCodeCamp',
repo: 'freeCodeCamp',
issue_number: PRNumber,
labels: [
"crowdin-sync",
"scope: i18n",
"scope: docs"
]
});
await github.pulls.requestReviewers({
owner: 'freeCodeCamp',
repo: 'freeCodeCamp',
pull_number: PRNumber,
reviewers: [
'RandellDawson',
'nhcarrigan'
]
});