-
Notifications
You must be signed in to change notification settings - Fork 6.5k
139 lines (118 loc) · 5.6 KB
/
translations-sync.yml
File metadata and controls
139 lines (118 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# 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 Download
on:
workflow_dispatch: # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages
schedule:
- cron: '0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations.
# Cancel any runs on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
BRANCH_NAME: chore/crowdin
jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
# see all the options at https://github.com/crowdin/github-action
- name: Crowdin PR
uses: crowdin/github-action@9fd07c1c5b36b15f082d1d860dc399f16f849bd7 # v2.9.0
with:
# do not upload anything - this is a one-way operation download
upload_sources: false
upload_translations: false
# the rest of this controls how the PR comes in with new translations
download_translations: true
localization_branch_name: ${{ env.BRANCH_NAME }}
create_pull_request: true
pull_request_title: '[automated]: crowdin sync'
pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
commit_message: 'chore: synced translations from crowdin'
env:
GITHUB_TOKEN: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
# A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
# Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
format_crowdin_pull_request:
needs: synchronize-with-crowdin
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@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- name: Git Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ env.BRANCH_NAME }}
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }}
fetch-depth: -1
- 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
- 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
- name: Run ESLint
working-directory: apps/site
run: node --run lint:md -- --fix
- name: Run Prettier
run: node --run prettier:fix
- name: Patch version if the files changed
run: |
CHANGED_FILES=$(git diff --name-only $BEFORE HEAD -- packages/website-i18n)
if [ -n "$CHANGED_FILES" ]; then
cd packages/website-i18n
pnpm version patch --no-git-tag-version
fi
env:
BEFORE: ${{ github.event.before }}
- name: Push Changes back to Pull Request
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
with:
commit_options: '--no-verify --signoff'
commit_message: 'chore: automated format of translated files'
branch: ${{ env.BRANCH_NAME }}
- name: Save Lint Cache
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
apps/site/.eslintmdcache
apps/site/.prettiercache
key: cache-lint-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('apps/site/.eslintmdcache') }}