-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
114 lines (101 loc) · 3.95 KB
/
Copy pathaction.yml
File metadata and controls
114 lines (101 loc) · 3.95 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: 'DeepWork Review Action'
description: 'Run DeepWork reviews via Claude Code on a PR, auto-commit improvements, and add inline PR review comments'
author: 'Unsupervisedcom'
branding:
icon: 'check-circle'
color: 'blue'
inputs:
anthropic_api_key:
description: 'Anthropic API key for Claude Code'
required: true
github_token:
description: 'GitHub token with write access to commit changes and post review comments'
required: true
model:
description: 'Claude model to use (e.g. claude-sonnet-4-6, claude-opus-4-6)'
required: false
default: 'claude-opus-4-6'
max_turns:
description: 'Maximum number of agentic turns for Claude Code'
required: false
default: '50'
commit_message:
description: 'Commit message for auto-committed review changes'
required: false
default: 'chore: apply DeepWork review suggestions'
runs:
using: 'composite'
steps:
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: 'latest'
- name: Restore DeepWork review cache
uses: actions/cache@v4
with:
path: .deepwork/tmp
# A unique save key per run ensures the cache is always updated with the
# latest review state after each run. restore-keys picks up the most recent
# cache for this PR so already-passed reviews are not re-run.
key: deepwork-review-pr-${{ github.event.pull_request.number }}-${{ github.run_id }}
restore-keys: |
deepwork-review-pr-${{ github.event.pull_request.number }}-
- name: Fetch base branch for git diff
shell: bash
run: |
BASE_REF="${{ github.event.pull_request.base.ref }}"
if [ -n "$BASE_REF" ]; then
git fetch origin "$BASE_REF" --depth=1 || \
echo "Warning: could not fetch base branch '$BASE_REF'; diff detection may be incomplete"
fi
- name: Prepare review run
shell: bash
run: |
# Clean up any leftover changes file from a previous run.
rm -f /tmp/deepwork_changes.json
- name: Run DeepWork review with Claude Code
uses: anthropics/claude-code-base-action@beta
env:
GH_TOKEN: ${{ inputs.github_token }}
with:
anthropic_api_key: ${{ inputs.anthropic_api_key }}
prompt_file: ${{ github.action_path }}/prompts/review.txt
plugin_marketplaces: https://github.com/Unsupervisedcom/deepwork.git
plugins: deepwork@deepwork-plugins
claude_args: >-
--dangerously-skip-permissions
--model ${{ inputs.model }}
--max-turns ${{ inputs.max_turns }}
- name: Commit and push changes
id: commit
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
git config user.name "deepwork-action[bot]"
git config user.email "deepwork-action[bot]@users.noreply.github.com"
# Check for any modified, added, or deleted tracked files
if git diff --quiet && git diff --cached --quiet \
&& [ -z "$(git ls-files --others --exclude-standard)" ]; then
echo "No changes to commit."
echo "changes_made=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "changes_made=true" >> "$GITHUB_OUTPUT"
git add -A
git commit -m "${{ inputs.commit_message }}"
# Authenticate push via the provided token.
REPO="${{ github.repository }}"
git remote set-url origin \
"https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.git"
git push
- name: Post inline PR review comments
if: steps.commit.outputs.changes_made == 'true' && github.event.pull_request.number != ''
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
python3 "${{ github.action_path }}/scripts/post-review-comments.py"