Skip to content

Commit 9f77ab9

Browse files
committed
hotfix: move i18n formatting to sync workflow
1 parent be8ad11 commit 9f77ab9

File tree

4 files changed

+134
-147
lines changed

4 files changed

+134
-147
lines changed

.github/workflows/translations-pr-lint-and-format.yml

Lines changed: 0 additions & 140 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This Workflow is used to comment on PRs that have changes that touch Translated Files
2+
# and then comments on their PRs mentioning that they should not do so
3+
4+
name: Incoming Translation Checks
5+
6+
on:
7+
# run when someone tries to manually change localized content
8+
pull_request_target:
9+
branches:
10+
- main
11+
paths:
12+
- 'apps/site/pages/**/*.md'
13+
- 'apps/site/pages/**/*.mdx'
14+
- '!apps/site/pages/en/**/*.md'
15+
- '!apps/site/pages/en/**/*.mdx'
16+
- 'packages/i18n/locales/*.json'
17+
- '!packages/i18n/locales/en.json'
18+
19+
# Cancel any runs on the same branch
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
permissions:
25+
actions: read
26+
27+
jobs:
28+
comment_on_translation_pr:
29+
# This comment should always be posted on forks, or from internal PRs not originating from Crowdin (which are direct branches)
30+
if: |
31+
(github.event.pull_request.head.repo.full_name != 'nodejs/nodejs.org') ||
32+
(github.event.pull_request.head.repo.full_name == 'nodejs/nodejs.org' && github.event.pull_request.head.ref != 'chore/crowdin')
33+
34+
name: Comment on Translation PR
35+
runs-on: ubuntu-latest
36+
37+
permissions:
38+
# This permission is required by `thollander/actions-comment-pull-request`
39+
pull-requests: write
40+
41+
steps:
42+
- name: Harden Runner
43+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
44+
with:
45+
egress-policy: audit
46+
47+
- uses: thollander/actions-comment-pull-request@e2c37e53a7d2227b61585343765f73a9ca57eda9 # v3.0.0
48+
with:
49+
message: |
50+
> [!NOTE]\
51+
> Your Pull Request seems to be updating **Translations** of the Node.js Website.
52+
>
53+
> Whilst we appreciate your intent; Any Translation update should be done through our [Crowdin Project](https://crowdin.com/project/nodejs-web).
54+
> We recommend giving a read on our [Translation Guidelines](https://github.com/nodejs/nodejs.org/blob/main/TRANSLATION.md).
55+
>
56+
> Thank you!
57+
comment-tag: use_crowdin

.github/workflows/translations-sync.yml

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# This action automates the synchronization of our crowdin translations, so that a human does not need to kick it off from the crowdin UI
2+
# It also formats incoming content because it is often not adherent to our rules post-translation.
3+
24
# See translations-upload.yml for automation to upload our source content
3-
# See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations.
5+
# See translations-pr-lint.yml for quality control we conduct on ingress of new translations.
46
name: Crowdin Download
57

68
on:
@@ -28,11 +30,9 @@ jobs:
2830
with:
2931
egress-policy: audit
3032

31-
- name: Checkout
32-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33-
3433
# see all the options at https://github.com/crowdin/github-action
35-
- name: crowdin action
34+
- name: Crowdin PR
35+
id: crowdin
3636
uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da # v2.3.0
3737
with:
3838
# do not upload anything - this is a one-way operation download
@@ -44,11 +44,81 @@ jobs:
4444
create_pull_request: true
4545
pull_request_title: '[automated]: crowdin sync'
4646
pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
47-
pull_request_labels: github_actions:pull-request
4847
commit_message: 'chore: synced translations from crowdin'
4948
env:
5049
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5150
# A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api
5251
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
5352
# Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot
5453
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
54+
55+
format_crowdin_pull_request:
56+
runs-on: ubuntu-latest
57+
58+
permissions:
59+
# This permission is required by `stefanzweifel/git-auto-commit-action`
60+
contents: write
61+
62+
steps:
63+
- name: Harden Runner
64+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
65+
with:
66+
egress-policy: audit
67+
68+
- name: Git Checkout
69+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
70+
with:
71+
# Use the number from the output of crowdin/github-action
72+
ref: refs/pull/${{ steps.crowdin.outputs.pull_request_number }}/head
73+
74+
- name: Restore Lint Cache
75+
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
76+
with:
77+
path: |
78+
apps/site/.eslintmdcache
79+
apps/site/.prettiercache
80+
# We want to restore Turborepo Cache and ESlint and Prettier Cache
81+
# The ESLint and Prettier cache's are useful to reduce the overall runtime of ESLint and Prettier
82+
# as they will only run on files that have changed since the last cached run
83+
# this might of course lead to certain files not being checked against the linter, but the chances
84+
# of such situation from happening are very slim as the checksums of both files would need to match
85+
key: cache-lint-${{ hashFiles('package-lock.json') }}-
86+
restore-keys: |
87+
cache-lint-${{ hashFiles('package-lock.json') }}-
88+
cache-lint-
89+
90+
- name: Set up Node.js
91+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
92+
with:
93+
# We want to ensure that the Node.js version running here respects our supported versions
94+
node-version-file: '.nvmrc'
95+
cache: 'npm'
96+
97+
- name: Install npm packages
98+
# We want to avoid npm from running the Audit Step and Funding messages on a CI environment
99+
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
100+
run: npm i --no-audit --no-fund --ignore-scripts --userconfig=/dev/null
101+
102+
- name: Run `npx lint:md --fix`
103+
# This runs a specific version of ESLint with only the Translation Pages Globbing
104+
# This avoid that unrelated changes get linted/modified within this PR
105+
run: npx eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js
106+
107+
- name: Run `npx prettier --write`
108+
# This runs a specific version of Prettier with only the Translation Pages Globbing
109+
# This avoid that unrelated changes get prettied/modified within this PR
110+
run: npx prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache
111+
112+
- name: Push Changes back to Pull Request
113+
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
114+
with:
115+
commit_options: '--no-verify --signoff'
116+
commit_message: 'chore: automated format of translated files'
117+
118+
- name: Save Lint Cache
119+
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
120+
with:
121+
path: |
122+
apps/site/.eslintmdcache
123+
apps/site/.prettiercache
124+
key: cache-lint-${{ hashFiles('package-lock.json') }}-${{ hashFiles('apps/site/.eslintmdcache') }}

.github/workflows/translations-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This action automates the upload of our source content to crowdin.
22
# See translations-sync.yml for the automation to download new translations on a schedule
3-
# See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations.
3+
# See translations-pr-lint.yml for quality control we conduct on ingress of new translations.
44
name: Crowdin Upload
55

66
on:

0 commit comments

Comments
 (0)