Skip to content

Commit 0bedbc3

Browse files
committed
fix:targger ui
1 parent 400c6a6 commit 0bedbc3

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/pr-validate.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
paths:
77
- 'tools/**'
88
workflow_dispatch:
9+
inputs:
10+
pr_number:
11+
description: 'PR number to validate'
12+
required: true
913

1014
jobs:
1115
validate:
@@ -21,7 +25,14 @@ jobs:
2125
fetch-depth: 0
2226

2327
- name: Get changed files
24-
run: git diff --name-only origin/main...HEAD > changed_files.txt
28+
run: |
29+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
30+
gh pr diff ${{ inputs.pr_number }} --name-only > changed_files.txt
31+
else
32+
git diff --name-only origin/main...HEAD > changed_files.txt
33+
fi
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2536

2637
- name: Set up Python
2738
uses: actions/setup-python@v5
@@ -40,7 +51,7 @@ jobs:
4051
cat result.txt
4152
4253
- name: Comment on PR
43-
if: github.event_name == 'pull_request'
54+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
4455
uses: actions/github-script@v7
4556
with:
4657
script: |
@@ -49,8 +60,11 @@ jobs:
4960
const exitCode = '${{ steps.validate.outputs.exit_code }}';
5061
const icon = exitCode === '0' ? '✅' : '❌';
5162
const status = exitCode === '0' ? '校验通过' : '校验失败,请修复后重新提交';
63+
const prNumber = context.eventName === 'workflow_dispatch'
64+
? parseInt('${{ inputs.pr_number }}')
65+
: context.payload.pull_request.number;
5266
github.rest.issues.createComment({
53-
issue_number: context.payload.pull_request.number,
67+
issue_number: prNumber,
5468
owner: context.repo.owner,
5569
repo: context.repo.repo,
5670
body: `## ${icon} PR 自动校验结果\n\n**状态**: ${status}\n\n\`\`\`\n${result}\n\`\`\``

0 commit comments

Comments
 (0)