Skip to content

Commit d3c3d92

Browse files
committed
Refactor code review workflow to sanitize diff output and update artifact naming
1 parent 9df447e commit d3c3d92

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/code-review.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ jobs:
3434
echo "Generating diff between ${{ github.base_ref }} and ${{ github.head_ref }}"
3535
git diff origin/${{ github.base_ref }}...${{ github.head_ref }} > changes.diff
3636
37+
# Step 4: Sanitize the diff file
38+
- name: Sanitize Diff
39+
run: |
40+
# Remove metadata lines and retain only actual code changes (+/-)
41+
grep -E '^(\+|-)' changes.diff | sed 's/^+/Added: /; s/^-/Removed: /' > sanitized_diff.txt
42+
3743
# Step 4: Upload the diff file as an artifact (optional)
3844
- name: Upload Diff as Artifact
3945
uses: actions/upload-artifact@v4
4046
with:
41-
name: pr-diff
42-
path: changes.diff
47+
name: sanitized-pr-diff
48+
path: sanitized_diff.txt
4349

4450
# Step 5: Install Ollama
4551
- name: Install Ollama
@@ -57,7 +63,7 @@ jobs:
5763
- name: Prepare Prompt
5864
id: prepare-prompt
5965
run: |
60-
DIFF=$(cat changes.diff)
66+
DIFF=$(cat sanitized_diff.txt)
6167
PROMPT=$(echo "Please review the following code changes and provide feedback:\n\n$DIFF\n\nFeedback:" | sed 's/"/\\"/g')
6268
echo "prompt=$PROMPT" >> $GITHUB_ENV
6369

0 commit comments

Comments
 (0)