-
Notifications
You must be signed in to change notification settings - Fork 333
feat: add auot build main module docs yml #3907
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
Conversation
WalkthroughAdds a GitHub Actions workflow that triggers on pull requests and pushes to the dev branch to checkout repositories and submodules, install dependencies with pnpm, build the docs site, and report build status to the PR. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant GH as GitHub Actions
participant Runner as Ubuntu Runner
participant SSH as SSH Agent
participant GitHubRepo as Tiny-Vue Submodule Repo
participant DocsRepo as Main Docs Repo
participant PNPM as pnpm Build
GH->>Runner: trigger on pull_request / push (dev)
Runner->>SSH: start agent using SUBMODULE_SSH_KEY
Runner->>GitHubRepo: checkout submodule (fetch-depth:0, PR head)
Runner->>DocsRepo: clone docs repo, sync & init submodules
Runner->>GitHubRepo: update submodule ref (commit if needed)
Runner->>PNPM: setup pnpm v9
Runner->>PNPM: run `pnpm i` then `pnpm build` in docs
PNPM-->>Runner: build success / failure
Runner->>GH: update PR status (success or failure)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (2)
.github/workflows/auto-build-main-module-docs.yml (2)
12-14: Permissionpull-requests: writeis granted but not utilized.The workflow declares
pull-requests: writepermission but never actually updates the PR status via the GitHub API. The "Update PR status" step only prints to the console.If you intend to post build results to the PR, consider using an action like
actions/github-scriptor the GitHub CLI:- name: Update PR status if: always() && github.event_name == 'pull_request' uses: actions/github-script@v7 with: script: | const status = '${{ job.status }}' === 'success' ? '✅ 主仓库构建成功' : '❌ 主仓库构建失败'; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: status });Otherwise, remove the unused permission.
50-53: Consider specifying Node.js version for consistency.While pnpm version 9 is specified, no Node.js version is set. This relies on the default Node.js version in ubuntu-latest, which may change over time.
Add a Node.js setup step before pnpm:
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' # or your preferred version - name: Setup pnpm uses: pnpm/action-setup@v3 with: version: 9
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/auto-build-main-module-docs.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.9)
.github/workflows/auto-build-main-module-docs.yml
27-27: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
(expression)
🔇 Additional comments (2)
.github/workflows/auto-build-main-module-docs.yml (2)
20-24: Checkout configuration looks good.Using
fetch-depth: 0ensures full git history is available, which is appropriate for submodule operations.
55-60: Build commands look appropriate.The build steps correctly use the
working-directoryand execute standard pnpm commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
.github/workflows/auto-build-main-module-docs.yml (3)
3-7: Workflow will fail on push events due to missing branch reference.This issue was previously flagged:
github.head_refon line 39 is only available for pull_request events, not push events. The workflow needs to either remove the push trigger or handle both event types differently.
36-41: Script injection vulnerability using untrusted input.This issue was previously flagged: Using
${{ github.head_ref }}directly in shell script creates a script injection risk. The fix is to pass it through an environment variable.
47-48: Git commit will fail without user configuration.This issue was previously flagged: The
git commitcommand requires user identity configuration in the Actions runner.
🧹 Nitpick comments (1)
.github/workflows/auto-build-main-module-docs.yml (1)
63-72: Consider renaming step to match its actual behavior.The step is named "Update PR status" but only logs messages to the workflow console. It doesn't create PR comments or update GitHub status checks via the API, despite having
pull-requests: writepermission.Consider renaming to better reflect its purpose:
- - name: Update PR status + - name: Report build status if: always()
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/auto-build-main-module-docs.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.9)
.github/workflows/auto-build-main-module-docs.yml
27-27: "github.head_ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
(expression)
| if: always() | ||
| run: | | ||
| # 检查构建是否成功 | ||
| if [ ${{ steps.build.outcome }} == 'success' ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote the workflow expression in shell test for robustness.
The unquoted expression ${{ steps.build.outcome }} could cause a syntax error if the value is empty or contains unexpected characters.
Apply this diff:
- if [ ${{ steps.build.outcome }} == 'success' ]; then
+ if [ "${{ steps.build.outcome }}" == "success" ]; then📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [ ${{ steps.build.outcome }} == 'success' ]; then | |
| if [ "${{ steps.build.outcome }}" == "success" ]; then |
🤖 Prompt for AI Agents
.github/workflows/auto-build-main-module-docs.yml around line 67: the shell test
uses an unquoted workflow expression (${{
steps.build.outcome }}) which can cause syntax errors if empty or contains
spaces; update the test to wrap the expression in quotes so the shell sees a
single word (e.g., quote the substituted value on both sides of the comparison)
to make the condition robust and prevent failures when the variable is empty or
has special characters.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.