Crowdin Download #58
Workflow file for this run
This file contains hidden or 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 action automates the synchronization of our crowdin translations, so that a human does not need to kick it off from the crowdin UI | |
# It also formats incoming content because it is often not adherent to our rules post-translation. | |
# See translations-upload.yml for automation to upload our source content | |
# See translations-pr-lint.yml for quality control we conduct on ingress of new translations. | |
name: Crowdin Translations Sync | |
on: | |
workflow_dispatch: # Manual trigger for urgent fixes | |
schedule: | |
- cron: '0 5 * * 5' # Fridays at 05:00 UTC, allowing weekend review time | |
# Cancel any runs on the same branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: {} | |
env: | |
COMMIT_MSG: 'chore: sync translations from crowdin' | |
HEAD_REF: chore/crowdin | |
jobs: | |
sync-translations: | |
runs-on: ubuntu-latest | |
outputs: | |
pr_number: ${{ steps.crowdin_pr.outputs.pull_request_number }} | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | |
with: | |
egress-policy: audit | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} | |
# Downloads translations from Crowdin and creates a PR | |
# See all the options at https://github.com/crowdin/github-action | |
- name: Download Translations & Create PR | |
id: crowdin_pr | |
uses: crowdin/github-action@b8012bd5491b8aa8578b73ab5b5f5e7c94aaa6e2 # v2.7.0 | |
with: | |
upload_sources: false | |
upload_translations: false | |
download_translations: true | |
localization_branch_name: ${{ env.HEAD_REF }} | |
create_pull_request: true | |
pull_request_title: '[automated]: Crowdin Translations Sync' | |
pull_request_body: 'New translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)' | |
commit_message: ${{ env.COMMIT_MSG }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} | |
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | |
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | |
format-translations: | |
needs: sync-translations | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 | |
with: | |
egress-policy: audit | |
# Checks out the PR branch created by the previous job | |
- name: Checkout PR Branch | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
with: | |
ref: refs/pull/${{ needs.sync-translations.outputs.pr_number }}/head | |
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} | |
fetch-depth: 0 | |
- name: Restore Lint Cache | |
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
with: | |
path: | | |
apps/site/.eslintmdcache | |
apps/site/.prettiercache | |
# We want to restore Turborepo Cache and ESlint and Prettier Cache | |
# The ESLint and Prettier cache's are useful to reduce the overall runtime of ESLint and Prettier | |
# as they will only run on files that have changed since the last cached run | |
# this might of course lead to certain files not being checked against the linter, but the chances | |
# of such situation from happening are very slim as the checksums of both files would need to match | |
key: cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/site/.eslintmdcache') }} | |
restore-keys: | | |
cache-lint-${{ hashFiles('pnpm-lock.yaml') }}- | |
cache-lint- | |
- name: Set up pnpm | |
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
with: | |
cache: true | |
- name: Set up Node.js | |
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
with: | |
# We want to ensure that the Node.js version running here respects our supported versions | |
node-version-file: '.nvmrc' | |
cache: 'pnpm' | |
- name: Install packages | |
run: pnpm install --frozen-lockfile | |
# Re-stage latest commit and run lint-staged | |
- name: Re-stage and Format Files | |
run: | | |
# Soft reset to unstage the commit but keep changes | |
git reset --soft HEAD^ | |
# Run lint-staged on the staged files | |
# This will run linters/formatters only on changed files | |
# according to the configuration in package.json or .lintstagedrc | |
pnpm lint-staged | |
git commit -m "$COMMIT_MSG" --signoff | |
# Push the changes back to the PR branch | |
- name: Push Changes | |
run: git push origin HEAD:$HEAD_REF |