Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/sync-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Sync Vitest Docs

on:
workflow_dispatch:

jobs:
sync-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout docs-cn repository
uses: actions/checkout@v4
with:
repository: vitest-dev/docs-cn
ref: dev
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: |
npm install shelljs @octokit/rest colors
Comment on lines +23 to +25
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing dependencies globally with npm install in the workflow is inefficient since the repository already has a package.json with these dependencies. Use the project's package manager instead:

- name: Install pnpm
  uses: pnpm/action-setup@v4

- name: Install dependencies
  run: pnpm install
Suggested change
- name: Install dependencies
run: |
npm install shelljs @octokit/rest colors
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install

Copilot uses AI. Check for mistakes.
- name: Run sync script
env:
GITHUB_USERNAME: elonehoo
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded username "elonehoo" should be derived from the GitHub Actions context instead of being hardcoded. Use ${{ github.actor }} to get the user who triggered the workflow:

GITHUB_USERNAME: ${{ github.actor }}
Suggested change
GITHUB_USERNAME: elonehoo
GITHUB_USERNAME: ${{ github.actor }}

Copilot uses AI. Check for mistakes.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Comment on lines +16 to +30
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using secrets.GITHUB_TOKEN in a workflow_dispatch event will have limited permissions and may not be able to push to the repository or create pull requests. Consider using a Personal Access Token (PAT) stored as a repository secret with appropriate permissions:

token: ${{ secrets.PAT_TOKEN }}

Copilot uses AI. Check for mistakes.
GITHUB_EMAIL: [email protected]
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded email "[email protected]" should be dynamically generated based on the GitHub username or use GitHub Actions context:

GITHUB_EMAIL: ${{ github.actor }}@users.noreply.github.com
Suggested change
GITHUB_EMAIL: elonehoo@users.noreply.github.com
GITHUB_EMAIL: ${{ github.actor }}@users.noreply.github.com

Copilot uses AI. Check for mistakes.
run: |
node scripts/sync-vitest-docs.mjs "$GITHUB_USERNAME" "$GITHUB_TOKEN" "$GITHUB_EMAIL"
- name: Cleanup
if: always()
run: |
rm -rf temp
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"lint": "eslint --cache .",
"lint:fix": "eslint . --fix",
"generate-pwa-icons": "pwa-assets-generator",
"prepare": "simple-git-hooks"
"prepare": "simple-git-hooks",
"sync": "node scripts/sync-vitest-docs.mjs"
},
"dependencies": {
"@vueuse/core": "latest",
Expand Down Expand Up @@ -45,6 +46,9 @@
"lint-staged": "^16.2.6",
"ofetch": "^1.4.1",
"pathe": "^2.0.3",
"shelljs": "^0.8.5",
"@octokit/rest": "^21.0.2",
"colors": "^1.4.0",
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The colors package is imported in package.json but never used in the sync script. This dependency appears to be unnecessary and should be removed unless there's a specific plan to use it for terminal output formatting.

Suggested change
"colors": "^1.4.0",

Copilot uses AI. Check for mistakes.
"simple-git-hooks": "^2.13.1",
"tinyglobby": "latest",
"tsx": "^4.19.3",
Expand Down
181 changes: 181 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading