Skip to content

Commit

Permalink
Include crowdin workflow (#530)
Browse files Browse the repository at this point in the history
* Include crowdin workflow

* Update .github/workflows/crowdin-pull.yml

Co-authored-by: Chris Marslender <[email protected]>

* Update .github/workflows/crowdin-push.yml

Co-authored-by: Chris Marslender <[email protected]>

---------

Co-authored-by: Chris Marslender <[email protected]>
  • Loading branch information
BrandtH22 and cmmarslender authored Mar 29, 2024
1 parent 165e840 commit 950a51d
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/crowdin-pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Pull translations from Crowdin

on:
workflow_dispatch:
inputs:
pr_target:
description: "PR Target Branch for Updated Translations"
type: string
default: "main"
schedule:
- cron: "0 0 * * 0"

permissions:
id-token: write
contents: write
pull-requests: write

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}--${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true

jobs:
pull-from-crowdin:
runs-on: [k8s-public]
container: node:18
env:
localization_branch_name: l10n_crowdin_translations
steps:
- name: Add safe git directory
uses: Chia-Network/actions/git-mark-workspace-safe@main

- name: Checkout
uses: actions/checkout@v4
with:
ref: "${{ inputs.pr_target || github.ref_name }}"

- name: Vault Login
uses: Chia-Network/actions/vault/login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
role_name: github-chia-docs

- name: Get secrets from vault
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_URL }}
token: ${{ env.VAULT_TOKEN }}
secrets: |
secret/data/crowdin token | CROWDIN_PERSONAL_TOKEN;
secret/data/crowdin project-id-docs | CROWDIN_PROJECT_ID;
# Setting this up globally so that we can also commit the compiled translations after crowdin runs
- uses: Chia-Network/actions/commit-sign/gpg@main
with:
gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY_RSA }}
passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }}

- name: crowdin action
uses: crowdin/[email protected]
with:
upload_sources: false
upload_translations: false
download_translations: true
crowdin_branch_name: main
localization_branch_name: ${{ env.localization_branch_name }}
create_pull_request: true
pull_request_title: "New Crowdin Translations"
pull_request_body: "New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)"
pull_request_base_branch_name: "${{ inputs.pr_target || 'main' }}"
github_user_name: "Chia Automation"
github_user_email: "[email protected]"
gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY_RSA }}
gpg_passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }}
skip_ref_checkout: "true"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Compile Updated translations
run: |
npm install
npm run locale
(git add . && git commit -m "Compiled Translations" && git push origin ${{ env.localization_branch_name }}) || true
44 changes: 44 additions & 0 deletions .github/workflows/crowdin-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Push strings to Crowdin

on:
push:
branches:
- main
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
push-to-crowdin:
runs-on: [k8s-public]
container: node:18
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Vault Login
uses: Chia-Network/actions/vault/login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
role_name: github-chia-docs

- name: Get secrets from vault
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_URL }}
token: ${{ env.VAULT_TOKEN }}
secrets: |
secret/data/crowdin token | CROWDIN_PERSONAL_TOKEN;
secret/data/crowdin project-id-docs | CROWDIN_PROJECT_ID;
- name: crowdin action
uses: crowdin/[email protected]
with:
upload_sources: true
upload_translations: false
download_translations: false
crowdin_branch_name: ${{ github.ref_name }} # The "branch" (folder) in crowdin to source from. Match the branch name in GH
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 950a51d

Please sign in to comment.