Skip to content

[automated]: crowdin sync #855

[automated]: crowdin sync

[automated]: crowdin sync #855

Workflow file for this run

# This Workflow is used to comment on PRs that have changes that touch Translated Files
# and then comments on their PRs mentioning that they should not do so
name: Crowdin Checks
on:
pull_request_target:
branches:
- main
paths:
- 'apps/site/pages/**/*.md'
- 'apps/site/pages/**/*.mdx'
- '!apps/site/pages/en/**/*.md'
- '!apps/site/pages/en/**/*.mdx'
- 'packages/i18n/locales/*.json'
- '!packages/i18n/locales/en.json'
# Cancel any runs on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
actions: read
jobs:
comment_on_translation_pr:
# This comment should always be posted on forks, or from internal PRs not originating from Crowdin (which are direct branches)
if: |
(github.event.pull_request.head.repo.full_name != 'nodejs/nodejs.org') ||
(github.event.pull_request.head.repo.full_name == 'nodejs/nodejs.org' && github.event.pull_request.head.ref != 'chore/crowdin')
name: Comment on Translation PR
runs-on: ubuntu-latest
permissions:
# This permission is required by `thollander/actions-comment-pull-request`
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0
with:
message: |
> [!NOTE]\
> Your Pull Request seems to be updating **Translations** of the Node.js Website.
>
> Whilst we appreciate your intent; Any Translation update should be done through our [Crowdin Project](https://crowdin.com/project/nodejs-web).
> We recommend giving a read on our [Translation Guidelines](https://github.com/nodejs/nodejs.org/blob/main/TRANSLATION.md).
>
> Thank you!
comment_tag: use_crowdin
format_crowdin_pull_request:
# We should only run the automated Format Command on Crowdin-based Pull Requests
if: |
github.event.pull_request.head.repo.full_name == 'nodejs/nodejs.org' &&
github.event.pull_request.head.ref == 'chore/crowdin'
name: Format Crowdin Pull Request
runs-on: ubuntu-latest
permissions:
# This permission is required by `stefanzweifel/git-auto-commit-action`
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Git Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
# Provides the Pull Request commit SHA or the GitHub merge group ref
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- name: Restore Lint Cache
uses: actions/cache/restore@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0
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('package-lock.json') }}-
restore-keys: |
cache-lint-${{ hashFiles('package-lock.json') }}-
cache-lint-
- name: Set up Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
# We want to ensure that the Node.js version running here respects our supported versions
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install npm packages
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
run: npm i --no-audit --no-fund --ignore-scripts --userconfig=/dev/null
- name: Run `npx lint:md --fix`
# This runs a specific version of ESLint with only the Translation Pages Globbing
# This avoid that unrelated changes get linted/modified within this PR
run: npx eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js
- name: Run `npx prettier --write`
# This runs a specific version of Prettier with only the Translation Pages Globbing
# This avoid that unrelated changes get prettied/modified within this PR
run: npx prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache
- name: Push Changes back to Pull Request
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
with:
commit_options: '--no-verify --signoff'
commit_message: 'chore: automated format of translated files'
- name: Save Lint Cache
uses: actions/cache/save@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0
with:
path: |
apps/site/.eslintmdcache
apps/site/.prettiercache
key: cache-lint-${{ hashFiles('package-lock.json') }}-${{ hashFiles('apps/site/.eslintmdcache') }}