Skip to content
Closed
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
68 changes: 68 additions & 0 deletions .github/workflows/auto-build-main-module-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Auto Build Main Module Docs

on:
pull_request:
branches: [dev]
push:
branches: [dev]

jobs:
verify-main-build:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.SUBMODULE_SSH_KEY_PRIVATE }}
- name: Checkout submodule repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}

- name: Checkout main repository
run: |
# 克隆主仓库
git clone https://github.com/opentiny/docs.git docs
cd docs

# 更新子模块到PR分支的版本
git submodule sync --recursive
git submodule update --init --recursive


# 获取PR分支的最新提交
cd ./tiny-vue
BRANCH_NAME="${{ github.head_ref }}"
git fetch origin $BRANCH_NAME
git checkout $BRANCH_NAME

# 回到主仓库根目录
cd ../

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9

- name: Run main repo build
id: build
working-directory: ./docs
run: |
pnpm i
# 如果使用VitePress
pnpm build

- name: Update PR status
if: always()
run: |
# 检查构建是否成功
if [ ${{ steps.build.outcome }} == 'success' ]; then
echo "✅ 主仓库构建成功"
else
echo "❌ 主仓库构建失败"
exit 1
fi
Comment on lines +59 to +68
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix comparison syntax and consider actual PR status update.

Line 67 has a syntax issue with the shell comparison. The ${{ }} expression should be quoted or use GitHub's built-in expression syntax.

Additionally, this step only echoes the status and exits—it doesn't actually update the PR with a comment or status check as the step name suggests.

Apply this diff to fix the comparison:

       run: |
         # 检查构建是否成功
-        if [ ${{ steps.build.outcome }} == 'success' ]; then
+        if [ "${{ steps.build.outcome }}" == "success" ]; then
           echo "✅ 主仓库构建成功"
         else
           echo "❌ 主仓库构建失败"
           exit 1
         fi

If you want to actually update the PR, add a step using actions/github-script or the GitHub CLI to post a comment:

    - name: Comment on PR
      if: always() && github.event_name == 'pull_request'
      uses: actions/github-script@v7
      with:
        script: |
          const outcome = '${{ steps.build.outcome }}';
          const message = outcome === 'success' 
            ? '✅ Main repo docs build succeeded'
            : '❌ Main repo docs build failed';
          github.rest.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: message
          });
🤖 Prompt for AI Agents
.github/workflows/auto-build-main-module-docs.yml lines 63-72: the shell
comparison uses an unquoted GitHub expression which breaks the if check and the
step only echoes status instead of updating the PR; change the if to use a
proper GitHub expression (for example quote the expression or use github's if:
expression syntax) or quote the expanded variable when used in shell, and
replace the echo/exit block with a real PR update step — add a follow-up step
that runs on always() and uses actions/github-script or the GitHub CLI to post a
comment or create a status check on the pull request indicating success or
failure, passing the build outcome into that script.

Loading