3
3
4
4
# See translations-upload.yml for automation to upload our source content
5
5
# See translations-pr-lint.yml for quality control we conduct on ingress of new translations.
6
- name : Crowdin Download
6
+ name : Crowdin Translations Sync
7
7
8
8
on :
9
- workflow_dispatch : # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages
9
+ workflow_dispatch : # Manual trigger for urgent fixes
10
10
schedule :
11
- - cron : ' 0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations.
11
+ - cron : ' 0 5 * * 5' # Fridays at 05:00 UTC, allowing weekend review time
12
12
13
13
# Cancel any runs on the same branch
14
14
concurrency :
15
15
group : ${{ github.workflow }}-${{ github.ref }}
16
16
cancel-in-progress : true
17
17
18
- permissions :
19
- contents : read
18
+ permissions : {}
19
+
20
+ env :
21
+ COMMIT_MSG : ' chore: sync translations from crowdin'
22
+ HEAD_REF : chore/crowdin
20
23
21
24
jobs :
22
- synchronize-with-crowdin :
25
+ sync-translations :
23
26
runs-on : ubuntu-latest
24
27
outputs :
25
- pull_request_number : ${{ steps.crowdin_pr.outputs.pull_request_number }}
26
-
28
+ pr_number : ${{ steps.crowdin_pr.outputs.pull_request_number }}
27
29
steps :
28
30
- name : Harden Runner
29
31
uses : step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
@@ -35,48 +37,41 @@ jobs:
35
37
with :
36
38
token : ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
37
39
38
- # see all the options at https://github.com/crowdin/github-action
39
- - name : Crowdin PR
40
- uses : crowdin/github-action@b8012bd5491b8aa8578b73ab5b5f5e7c94aaa6e2 # v2.7.0
40
+ # Downloads translations from Crowdin and creates a PR
41
+ # See all the options at https://github.com/crowdin/github-action
42
+ - name : Download Translations & Create PR
41
43
id : crowdin_pr
44
+ uses : crowdin/github-action@b8012bd5491b8aa8578b73ab5b5f5e7c94aaa6e2 # v2.7.0
42
45
with :
43
- # do not upload anything - this is a one-way operation download
44
46
upload_sources : false
45
47
upload_translations : false
46
- # the rest of this controls how the PR comes in with new translations
47
48
download_translations : true
48
- localization_branch_name : chore/crowdin
49
+ localization_branch_name : ${{ env.HEAD_REF }}
49
50
create_pull_request : true
50
- pull_request_title : ' [automated]: crowdin sync '
51
- pull_request_body : ' New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
52
- commit_message : ' chore: synced translations from crowdin '
51
+ pull_request_title : ' [automated]: Crowdin Translations Sync '
52
+ pull_request_body : ' New translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
53
+ commit_message : ${{ env.COMMIT_MSG }}
53
54
env :
54
55
GITHUB_TOKEN : ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
55
- # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api
56
56
CROWDIN_PROJECT_ID : ${{ secrets.CROWDIN_PROJECT_ID }}
57
- # Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot
58
57
CROWDIN_PERSONAL_TOKEN : ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
59
58
60
- format_crowdin_pull_request :
61
- needs : synchronize-with-crowdin
59
+ format-translations :
60
+ needs : sync-translations
62
61
runs-on : ubuntu-latest
63
-
64
- permissions :
65
- # This permission is required by `stefanzweifel/git-auto-commit-action`
66
- contents : write
67
-
68
62
steps :
69
63
- name : Harden Runner
70
- uses : step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
64
+ uses : step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
71
65
with :
72
66
egress-policy : audit
73
67
74
- - name : Git Checkout
75
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
68
+ # Checks out the PR branch created by the previous job
69
+ - name : Checkout PR Branch
70
+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
76
71
with :
77
- # Use the number from the output of crowdin/github-action
78
- ref : refs/pull/${{ needs.synchronize-with-crowdin.outputs.pull_request_number }}/head
72
+ ref : refs/pull/${{ needs.sync-translations.outputs.pr_number }}/head
79
73
token : ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
74
+ fetch-depth : 0
80
75
81
76
- name : Restore Lint Cache
82
77
uses : actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
@@ -109,27 +104,19 @@ jobs:
109
104
- name : Install packages
110
105
run : pnpm install --frozen-lockfile
111
106
112
- - name : Run `lint:md --fix`
113
- # This runs a specific version of ESLint with only the Translation Pages Globbing
114
- # This avoid that unrelated changes get linted/modified within this PR
115
- run : pnpm exec eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js
107
+ # Re-stage latest commit and run lint-staged
108
+ - name : Re-stage and Format Files
109
+ run : |
110
+ # Soft reset to unstage the commit but keep changes
111
+ git reset --soft HEAD^
116
112
117
- - name : Run `prettier --write`
118
- # This runs a specific version of Prettier with only the Translation Pages Globbing
119
- # This avoid that unrelated changes get prettied/modified within this PR
120
- run : pnpm exec prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache
113
+ # Run lint-staged on the staged files
114
+ # This will run linters/formatters only on changed files
115
+ # according to the configuration in package.json or .lintstagedrc
116
+ pnpm lint-staged
121
117
122
- - name : Push Changes back to Pull Request
123
- uses : stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
124
- with :
125
- commit_options : ' --no-verify --signoff'
126
- commit_message : ' chore: automated format of translated files'
127
- branch : ' chore/crowdin'
118
+ git commit -m "$COMMIT_MSG" --signoff
128
119
129
- - name : Save Lint Cache
130
- uses : actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
131
- with :
132
- path : |
133
- apps/site/.eslintmdcache
134
- apps/site/.prettiercache
135
- key : cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/site/.eslintmdcache') }}
120
+ # Push the changes back to the PR branch
121
+ - name : Push Changes
122
+ run : git push origin HEAD:$HEAD_REF
0 commit comments