-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix(crowdin): workflow improvements #7755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba60384
fix(crowdin): workflow improvements
avivkeller e05b072
fixup! fix(crowdin): workflow improvements
avivkeller 718d86f
fixup! fixup! fix(crowdin): workflow improvements
avivkeller cc94f9c
fixup! fixup! fixup! fix(crowdin): workflow improvements
avivkeller f55381f
[automated]: Crowdin Translations Sync (#7756)
nodejs-crowdin ab2e13a
Update translations-sync.yml
avivkeller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,27 @@ | |
|
||
# 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 | ||
name: Crowdin Translations Sync | ||
|
||
on: | ||
workflow_dispatch: # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages | ||
workflow_dispatch: # Manual trigger for urgent fixes | ||
schedule: | ||
- cron: '0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations. | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- cron: '0 5 * * 5' # Fridays at 05:00 UTC, allowing weekend review time | ||
|
||
# Cancel any runs on the same branch | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
permissions: {} | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
env: | ||
COMMIT_MSG: 'chore: sync translations from crowdin' | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
HEAD_REF: chore/crowdin | ||
|
||
jobs: | ||
synchronize-with-crowdin: | ||
sync-translations: | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
runs-on: ubuntu-latest | ||
outputs: | ||
pull_request_number: ${{ steps.crowdin_pr.outputs.pull_request_number }} | ||
|
||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | ||
|
@@ -35,48 +35,46 @@ jobs: | |
with: | ||
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} | ||
|
||
# see all the options at https://github.com/crowdin/github-action | ||
- name: Crowdin PR | ||
# Downloads translations from Crowdin and creates a PR | ||
# See all the options at https://github.com/crowdin/github-action | ||
- name: Download Translations & Create PR | ||
uses: crowdin/github-action@b8012bd5491b8aa8578b73ab5b5f5e7c94aaa6e2 # v2.7.0 | ||
id: crowdin_pr | ||
with: | ||
# do not upload anything - this is a one-way operation download | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: chore/crowdin | ||
localization_branch_name: ${{ env.HEAD_REF }} | ||
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' | ||
pull_request_title: '[automated]: Crowdin Translations Sync' | ||
pull_request_body: 'New translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)' | ||
commit_message: ${{ env.COMMIT_MSG }} | ||
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 | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | ||
|
||
format_crowdin_pull_request: | ||
needs: synchronize-with-crowdin | ||
format-translations: | ||
needs: sync-translations | ||
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@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Git Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
# Checks out the PR branch created by the previous job | ||
- name: Checkout PR Branch | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
with: | ||
# Use the number from the output of crowdin/github-action | ||
ref: refs/pull/${{ needs.synchronize-with-crowdin.outputs.pull_request_number }}/head | ||
ref: ${{ env.HEAD_REF }} | ||
token: ${{ secrets.CROWDIN_GITHUB_BOT_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
# Setup git user for commits | ||
- name: Setup Git User | ||
run: | | ||
git config --global user.name "nodejs-crowdin" | ||
git config --global user.email "[email protected]" | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Restore Lint Cache | ||
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | ||
|
@@ -109,27 +107,19 @@ jobs: | |
- name: Install packages | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run `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: pnpm exec eslint "apps/site/pages/**/*.md?(x)" --fix --cache --cache-strategy=metadata --cache-file=apps/site/.eslintmdcache --config=apps/site/eslint.config.js | ||
# Re-stage latest commit and run lint-staged | ||
- name: Re-stage and Format Files | ||
run: | | ||
# Soft reset to unstage the commit but keep changes | ||
git reset --soft HEAD^ | ||
|
||
- name: Run `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: pnpm exec prettier "apps/site/{pages,i18n}/**/*.{json,md,mdx}" --check --write --cache --cache-strategy=metadata --cache-location=apps/site/.prettiercache | ||
# Run lint-staged on the staged files | ||
# This will run linters/formatters only on changed files | ||
# according to the configuration in package.json or .lintstagedrc | ||
pnpm lint-staged | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Push Changes back to Pull Request | ||
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0 | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
commit_options: '--no-verify --signoff' | ||
commit_message: 'chore: automated format of translated files' | ||
branch: 'chore/crowdin' | ||
git commit -m "$COMMIT_MSG" --signoff --no-verify | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- 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') }} | ||
# Push the changes back to the PR branch | ||
- name: Push Changes | ||
run: git push origin HEAD:$HEAD_REF --force | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.