返回 CodeWhale
codewhale-review.yml
根目录 / .github / workflows / codewhale-review.yml
1 name: Codewhale PR Review
2 on:
3 workflow_dispatch:
4 inputs:
5 pr-number:
6 description: Pull request number
7 required: true
8 type: string
9 permissions: {}
10 concurrency:
11 group: codewhale-review-${{ github.event.pull_request.number || github.event.issue.number || inputs.pr-number }}
12 cancel-in-progress: false
13 jobs:
14 installation:
15 if: >-
16 github.actor != 'dependabot[bot]' &&
17 ((github.event_name == 'workflow_dispatch') ||
18 (github.event_name == 'pull_request' && !github.event.pull_request.draft && github.event.pull_request.head.repo.full_name == github.repository) ||
19 ((github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment') &&
20 (github.event.issue.pull_request || github.event.pull_request) &&
21 github.event.comment.user.type == 'User' && contains(github.event.comment.body, '@codewhale')))
22 runs-on: ubuntu-24.04
23 timeout-minutes: 5
24 permissions: {}
25 steps:
26 - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510
27 id: app-token
28 with:
29 app-id: ${{ vars.CODEWHALE_APP_ID }}
30 private-key: ${{ secrets.CODEWHALE_APP_PRIVATE_KEY }}
31 permission-contents: read
32 permission-pull-requests: write
33 review:
34 needs: installation
35 if: >-
36 github.actor != 'dependabot[bot]' &&
37 ((github.event_name == 'workflow_dispatch') ||
38 (github.event_name == 'pull_request' && !github.event.pull_request.draft && github.event.pull_request.head.repo.full_name == github.repository) ||
39 ((github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment') &&
40 (github.event.issue.pull_request || github.event.pull_request) &&
41 github.event.comment.user.type == 'User' && contains(github.event.comment.body, '@codewhale')))
42 runs-on: ubuntu-24.04
43 timeout-minutes: 25
44 permissions:
45 contents: read
46 pull-requests: read
47 outputs:
48 findings: ${{ steps.review.outputs.findings }}
49 steps:
50 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
51 with:
52 node-version: '22'
53 - uses: codewhale-hq/Codewhale@836ba652729f526d1727ebde7f66c3caf5656184
54 id: review
55 with:
56 version: 'v0.10.2'
57 provider: 'deepseek'
58 model: 'deepseek-flash'
59 reasoning-effort: 'off'
60 max-output-tokens: '16384'
61 pr-number: ${{ inputs.pr-number }}
62 trigger-phrase: '@codewhale'
63 allow-forks: 'true'
64 post: 'false'
65 env:
66 DEEPSEEK_API_KEY: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'issue_comment' || github.event.pull_request.head.repo.full_name == github.repository) && secrets.DEEPSEEK_API_KEY || '' }}
67 - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
68 if: steps.review.outputs.findings != ''
69 with:
70 name: codewhale-findings-${{ github.run_id }}-${{ github.run_attempt }}
71 path: ${{ steps.review.outputs.findings }}
72 retention-days: 1
73 if-no-files-found: error
74 - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
75 if: always() && steps.review.outputs.receipt != ''
76 with:
77 name: codewhale-review-receipt-${{ github.run_id }}-${{ github.run_attempt }}
78 path: ${{ steps.review.outputs.receipt }}
79 retention-days: 14
80 if-no-files-found: error
81 publish:
82 needs: review
83 if: needs.review.outputs.findings != ''
84 runs-on: ubuntu-24.04
85 timeout-minutes: 10
86 permissions:
87 contents: read
88 pull-requests: write
89 steps:
90 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
91 with:
92 node-version: '22'
93 - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
94 with:
95 name: codewhale-findings-${{ github.run_id }}-${{ github.run_attempt }}
96 path: findings
97 - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510
98 id: app-token
99 with:
100 app-id: ${{ vars.CODEWHALE_APP_ID }}
101 private-key: ${{ secrets.CODEWHALE_APP_PRIVATE_KEY }}
102 permission-contents: read
103 permission-pull-requests: write
104 - uses: codewhale-hq/Codewhale/scripts/github-action/publish@43c87b459914d58e056e207b99b270ba5ddebe74
105 id: publish
106 with:
107 findings: findings/findings.json
108 pr-number: ${{ inputs.pr-number }}
109 trigger-phrase: '@codewhale'
110 allow-forks: 'true'
111 github-token: ${{ steps.app-token.outputs.token }}
112 reviewer-login: 'codewhale-agent[bot]'
113 - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
114 if: always() && steps.publish.outputs.receipt != ''
115 with:
116 name: codewhale-publication-receipt-${{ github.run_id }}-${{ github.run_attempt }}
117 path: ${{ steps.publish.outputs.receipt }}
118 retention-days: 14
119 if-no-files-found: error
120
120 lines YAML