Repository navigation
Expand file tree
/
Copy pathgithub-action.yml
More file actions
64 lines (64 loc) · 2.45 KB
/
Copy pathgithub-action.yml
File metadata and controls
64 lines (64 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Preview-first workflow. Set CODETURTLE_REV to an audited full commit SHA.
# Automated fork review is intentionally outside this workflow's support scope.
name: CodeTurtle review
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
pr_number:
description: PR number to review
required: true
type: string
publish:
description: Publish the review after analysis
type: boolean
default: false
permissions:
contents: read
pull-requests: write
concurrency:
group: codeturtle-${{ github.repository }}-${{ github.event.pull_request.number || inputs.pr_number }}
cancel-in-progress: true
jobs:
review:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.draft != true)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.12'
- name: Install trusted reviewer
env:
TOOL_REV: ${{ vars.CODETURTLE_REV }}
run: |
[[ "$TOOL_REV" =~ ^[0-9a-fA-F]{40}$ ]] || { echo 'Set CODETURTLE_REV to a full audited commit SHA'; exit 1; }
python -m pip install "codeturtle-review[openai] @ git+https://github.com/venkatpachala/CodeTurtle.git@$TOOL_REV"
- name: Review data with trusted tooling
env:
GITHUB_TOKEN: ${{ github.token }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: ${{ vars.OPENAI_MODEL || 'gpt-4o-mini' }}
LLM_BACKEND: openai
GRAPHIFY_ENABLED: 'false'
CODETURTLE_HOME: ${{ runner.temp }}/codeturtle
REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number || inputs.pr_number }}
PUBLISH: ${{ inputs.publish || false }}
run: |
[[ "$PR" =~ ^[1-9][0-9]*$ ]] || exit 1
ARGS=(codeturtle review "$REPO" "$PR" --json-output review.json)
if [ "$PUBLISH" = 'true' ]; then ARGS+=(--comment); else ARGS+=(--dry-run); fi
"${ARGS[@]}"
- name: Preserve review result
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: codeturtle-review-${{ github.run_id }}
path: review.json
if-no-files-found: warn
retention-days: 7