File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 paths :
77 - ' tools/**'
88 workflow_dispatch :
9+ inputs :
10+ pr_number :
11+ description : ' PR number to validate'
12+ required : true
913
1014jobs :
1115 validate :
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
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 : |
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\`\`\``
You can’t perform that action at this time.
0 commit comments