@@ -15,16 +15,53 @@ jobs:
15
15
MODEL_NAME : " llama3.2:latest"
16
16
steps :
17
17
# Checkout the repository code
18
- - name : Checkout repository
18
+ - name : Checkout Repository
19
19
uses : actions/checkout@v4
20
20
with :
21
+ # Checks out the code from the pull request's head branch.
21
22
ref : ${{ github.event.pull_request.head.ref }}
23
+ fetch-depth : 0
24
+
25
+ # Fetches the base branch (e.g., main) from the remote repository
26
+ - name : Fetch base branch
27
+ run : |
28
+ git fetch origin ${{ github.base_ref }}
29
+
30
+ # - name: Fetch Pull Request Branch
31
+ # run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
32
+
33
+ - name : Generate Diff
34
+ id : generate-diff
35
+ run : |
36
+ echo "Generating diff between ${{ github.base_ref }} and ${{ github.head_ref }}"
37
+ DIFF=$(git diff origin/${{ github.base_ref }}...${{ github.head_ref }})
38
+ echo "diff_output<<EOF" >> $GITHUB_ENV
39
+ echo "$DIFF" >> $GITHUB_ENV
40
+ echo "EOF" >> $GITHUB_ENV
22
41
23
- - name : Fetch pull request branch
24
- run : git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
42
+ - name : Check Diff Size
43
+ id : check_diff_size
44
+ run : |
45
+ set -e
46
+ DIFF_SIZE=$(wc -c < change.diff)
47
+ echo "diff_size=$DIFF_SIZE" >> $GITHUB_OUTPUT
48
+ if (( DIFF_SIZE > 1000000 )); then
49
+ echo "Diff is too large, skipping review."
50
+ exit 0
51
+ fi
52
+
53
+ # Step 4: Output the diff (optional)
54
+ - name : Print diff
55
+ run : |
56
+ echo "Diff Output:"
57
+ echo "${{ env.diff_output }}"
25
58
26
- - name : Generate diff
59
+ # Step 5: Save the diff to a file (optional)
60
+ - name : Save diff to file
27
61
run : |
28
- git diff ${{ github.event.pull_request.base.sha }} pr-branch > change.diff
29
- echo "Diff generated successfully."
30
- echo "Diff content:" $(cat change.diff)
62
+ echo "${{ env.diff_output }}" > changes.diff
63
+
64
+ # - name: Install Ollama CLI
65
+ # run: |
66
+ # curl -fsSL https://ollama.com/install.sh | sh
67
+ # ollama --version
0 commit comments