|
1 | | -name: PR Code Review with LLM |
| 1 | +name: PR Code Review with AI |
2 | 2 |
|
3 | 3 | # Trigger the workflow when a pull request is opened or updated |
4 | 4 | on: |
|
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | code-review: |
| 11 | + name: Review Changes with AI |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 | permissions: |
13 | | - issues: write |
| 14 | + issues: write # Allows the workflow to write comments on issues and pull requests |
| 15 | + pull-requests: write # Allows the workflow to write comments on pull requests |
14 | 16 | env: |
15 | 17 | MODEL_NAME: "llama3.2:latest" |
16 | | - steps: |
17 | | - # Step 1: Checkout the repository code |
| 18 | + steps: |
18 | 19 | - name: Checkout Repository |
19 | 20 | uses: actions/checkout@v4 |
20 | 21 | with: |
21 | | - # Checks out the code from the pull request's head branch. |
22 | | - ref: ${{ github.event.pull_request.head.ref }} |
| 22 | + # Checks out the code from the pull request's head branch, the feature branch with changes. |
| 23 | + # ref: ${{ github.event.pull_request.head.ref }} |
23 | 24 | fetch-depth: 0 |
24 | 25 |
|
25 | | - # Step 2: Fetch 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 | | - # Step 3: Generate the diff between the base branch and the PR branch |
| 26 | + # - name: Fetch Base Branch |
| 27 | + # run: | |
| 28 | + # git fetch origin ${{ github.base_ref }} |
| 29 | + |
31 | 30 | - name: Generate Diff |
32 | 31 | id: generate-diff |
33 | 32 | run: | |
34 | 33 | echo "Generating diff between ${{ github.base_ref }} and ${{ github.head_ref }}" |
35 | | - git diff --unified=5 origin/${{ github.base_ref }}...${{ github.head_ref }} > changes.diff |
| 34 | + # git diff --unified=5 origin/${{ github.base_ref }}...${{ github.head_ref }} > changes.diff |
| 35 | + git diff --unified=0 origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} > changes.diff |
36 | 36 |
|
37 | | - # Step 4: Sanitize the diff file |
38 | 37 | - name: Sanitize Diff |
39 | 38 | run: | |
40 | 39 | # Remove metadata lines and retain only actual code changes (+/-) |
41 | 40 | grep -E '^(\+|-)' changes.diff | sed 's/^+/Added: /; s/^-/Removed: /' > sanitized_diff.txt |
42 | | - |
43 | | - |
44 | | - # Step 5: Upload the diff file as an artifact (optional) |
| 41 | + |
45 | 42 | - name: Upload Diff as Artifact |
46 | 43 | uses: actions/upload-artifact@v4 |
47 | 44 | with: |
|
0 commit comments