Skip to content

[🌐]: Crowdin Translations #511 #511

[🌐]: Crowdin Translations #511

[🌐]: Crowdin Translations #511 #511

Workflow file for this run

name: "Crowdin Translations"
run-name: "[🌐]: Crowdin Translations #${{ github.run_number }}"
on:
push:
branches: [dev]
paths:
- 'kubejs/assets/**/lang/en_us.json'
- 'kubejs/assets/**/patchouli_books/**/en_us/**/*.json'
workflow_dispatch:
inputs:
create_pr:
description: "Create Pull Request after sync"
type: boolean
default: false
required: true
schedule:
# Run daily at 3 AM UTC
- cron: '0 3 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
env:
LOCALIZATION_BRANCH: translations
TARGET_BRANCH: dev
jobs:
sync-patchouli:
name: "[🔄] Sync Patchouli"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v7
- name: "Crowdin"
uses: crowdin/github-action@v2
with:
upload_sources: true
download_translations: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
# skip_untranslated_files: true
# export_only_approved: true
create_pull_request: false
localization_branch_name: ${{ env.LOCALIZATION_BRANCH }}
pull_request_base_branch_name: ${{ env.TARGET_BRANCH }}
commit_message: "[translation] New translations"
config: .github/config/crowdin_patchouli.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
CROWDIN_ID: ${{ vars.CROWDIN_ID }}
sync-language:
name: "[🔄] Sync Language"
runs-on: ubuntu-latest
needs: [sync-patchouli]
steps:
- name: "Checkout repository"
uses: actions/checkout@v7
- name: "Crowdin"
uses: crowdin/github-action@v2
with:
upload_sources: true
download_translations: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
skip_untranslated_strings: true
# export_only_approved: true
create_pull_request: false
localization_branch_name: ${{ env.LOCALIZATION_BRANCH }}
pull_request_base_branch_name: ${{ env.TARGET_BRANCH }}
commit_message: "[translation] New translations"
config: .github/config/crowdin_lang.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
CROWDIN_ID: ${{ vars.CROWDIN_ID }}
cleanup-empty-files:
name: "[🗑️] Cleanup Empty Files"
runs-on: ubuntu-latest
needs: [sync-patchouli, sync-language]
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
steps:
- name: "Checkout translations branch"
uses: actions/checkout@v7
with:
ref: ${{ env.LOCALIZATION_BRANCH }}
fetch-depth: 0
continue-on-error: true
- name: "Remove empty translation files"
run: |
find kubejs/assets -name "*.json" -type f -exec sh -c 'jq -e "keys | length == 0" "$1" >/dev/null 2>&1 && rm "$1"' _ {} \;
- name: "Commit and push changes"
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "[translation] Remove empty translation files"
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
branch: ${{ env.LOCALIZATION_BRANCH }}
create-pr:
name: "[🤝] Create Pull Request"
runs-on: ubuntu-latest
needs: [cleanup-empty-files]
if: (github.event_name == 'schedule') || (github.event_name == 'workflow_dispatch' && inputs.create_pr)
steps:
- name: "Checkout repository"
uses: actions/checkout@v7
- name: "Generate GitHub App Token"
id: generate_token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: "Create Pull Request"
id: create_pr
uses: devops-infra/action-pull-request@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: ${{ env.LOCALIZATION_BRANCH }}
target_branch: ${{ env.TARGET_BRANCH }}
ignore_users: "dependabot"
label: "Pull request: Translation"
title: 'add: New Crowdin translations'
body: |
## 🌐 New translations from Crowdin
### 🔄 Changes
- Updated translation files
- Patchouli book translations
- name: "Automatically Merge PR"
uses: pascalgn/automerge-action@v0.16.4
env:
GITHUB_TOKEN: "${{ steps.generate_token.outputs.token }}"
MERGE_METHOD: "squash"
MERGE_LABELS: ""
MERGE_REQUIRED_APPROVALS: "0"
MERGE_DELETE_BRANCH: true
MERGE_READY_STATE: "clean,has_hooks,unknown,unstable,blocked"
PULL_REQUEST: ${{ steps.create_pr.outputs.pr_number }}