33
44# See translations-upload.yml for automation to upload our source content
55# See translations-pr-lint.yml for quality control we conduct on ingress of new translations.
6- name : Crowdin Translations Sync
6+ name : Crowdin Download
77
88on :
9- workflow_dispatch : # Manual trigger for urgent fixes
9+ workflow_dispatch : # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages
1010 schedule :
11- - cron : ' 0 5 * * 5' # Fridays at 05:00 UTC, allowing weekend review time
11+ - cron : ' 0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations.
1212
1313# Cancel any runs on the same branch
1414concurrency :
1515 group : ${{ github.workflow }}-${{ github.ref }}
1616 cancel-in-progress : true
1717
18- permissions : {}
18+ permissions :
19+ contents : read
1920
2021env :
21- COMMIT_MSG : ' chore: sync translations from crowdin'
22- HEAD_REF : chore/crowdin
22+ BRANCH_NAME : chore/crowdin
2323
2424jobs :
25- sync-translations :
25+ synchronize-with-crowdin :
2626 runs-on : ubuntu-latest
2727 steps :
2828 - name : Harden Runner
@@ -35,46 +35,46 @@ jobs:
3535 with :
3636 token : ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
3737
38- # Downloads translations from Crowdin and creates a PR
39- # See all the options at https://github.com/crowdin/github-action
40- - name : Download Translations & Create PR
38+ # see all the options at https://github.com/crowdin/github-action
39+ - name : Crowdin PR
4140 uses : crowdin/github-action@b8012bd5491b8aa8578b73ab5b5f5e7c94aaa6e2 # v2.7.0
4241 with :
42+ # do not upload anything - this is a one-way operation download
4343 upload_sources : false
4444 upload_translations : false
45+ # the rest of this controls how the PR comes in with new translations
4546 download_translations : true
46- localization_branch_name : ${{ env.HEAD_REF }}
47+ localization_branch_name : ${{ env.BRANCH_NAME }}
4748 create_pull_request : true
48- pull_request_title : ' [automated]: Crowdin Translations Sync '
49- pull_request_body : ' New translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
50- commit_message : ${{ env.COMMIT_MSG }}
49+ pull_request_title : ' [automated]: crowdin sync '
50+ pull_request_body : ' New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
51+ commit_message : ' chore: synced translations from crowdin '
5152 env :
5253 GITHUB_TOKEN : ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
54+ # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api
5355 CROWDIN_PROJECT_ID : ${{ secrets.CROWDIN_PROJECT_ID }}
56+ # Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot
5457 CROWDIN_PERSONAL_TOKEN : ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
5558
56- format-translations :
57- needs : sync-translations
59+ format_crowdin_pull_request :
60+ needs : synchronize-with-crowdin
5861 runs-on : ubuntu-latest
62+
63+ permissions :
64+ # This permission is required by `stefanzweifel/git-auto-commit-action`
65+ contents : write
66+
5967 steps :
6068 - name : Harden Runner
61- uses : step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
69+ uses : step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
6270 with :
6371 egress-policy : audit
6472
65- # Checks out the PR branch created by the previous job
66- - name : Checkout PR Branch
67- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
73+ - name : Git Checkout
74+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6875 with :
69- ref : ${{ env.HEAD_REF }}
76+ ref : ${{ env.BRANCH_NAME }}
7077 token : ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
71- fetch-depth : 0
72-
73- # Setup git user for commits
74- - name : Setup Git User
75- run : |
76- git config --global user.name "nodejs-crowdin"
77- git config --global user.email "nodejs-crowdin@users.noreply.github.com"
7878
7979 - name : Restore Lint Cache
8080 uses : actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
@@ -107,19 +107,24 @@ jobs:
107107 - name : Install packages
108108 run : pnpm install --frozen-lockfile
109109
110- # Re-stage latest commit and run lint-staged
111- - name : Re-stage and Format Files
112- run : |
113- # Soft reset to unstage the commit but keep changes
114- git reset --soft HEAD^
110+ - name : Run ESLint
111+ working-directory : apps/site
112+ run : pnpm lint:md --fix
115113
116- # Run lint-staged on the staged files
117- # This will run linters/formatters only on changed files
118- # according to the configuration in package.json or .lintstagedrc
119- pnpm lint-staged
114+ - name : Run Prettier
115+ run : pnpm prettier:fix
120116
121- git commit -m "$COMMIT_MSG" --signoff --no-verify
117+ - name : Push Changes back to Pull Request
118+ uses : stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
119+ with :
120+ commit_options : ' --no-verify --signoff'
121+ commit_message : ' chore: automated format of translated files'
122+ branch : ' chore/crowdin'
122123
123- # Push the changes back to the PR branch
124- - name : Push Changes
125- run : git push origin HEAD:$HEAD_REF --force
124+ - name : Save Lint Cache
125+ uses : actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
126+ with :
127+ path : |
128+ apps/site/.eslintmdcache
129+ apps/site/.prettiercache
130+ key : cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/site/.eslintmdcache') }}
0 commit comments