Skip to content

Commit da7a135

Browse files
committed
Fix running of ai analysis on forks
1 parent 541095f commit da7a135

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

.github/workflows/extension-ai-analysis.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Extension AI Analysis
33
on:
44
pull_request_target:
55
types: [opened, synchronize, reopened, ready_for_review]
6-
push:
7-
branches:
8-
- main
9-
- 5.*
106

117
concurrency:
128
group: ${{ github.workflow }}-${{ github.ref }}
@@ -21,11 +17,15 @@ jobs:
2117
pull-requests: write
2218
timeout-minutes: 30
2319
steps:
24-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20+
- name: Checkout the fork PR code
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2522
with:
23+
repository: ${{ github.event.pull_request.head.repo.full_name }}
24+
ref: ${{ github.event.pull_request.head.ref }}
2625
fetch-depth: 0 # Fetch full history for git diff
2726

28-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
27+
- name: Setup Python
28+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2929
with:
3030
python-version: "3.12"
3131
cache: "pip"
@@ -47,17 +47,13 @@ jobs:
4747
4848
- name: Get changed files
4949
run: |
50-
echo "Event: ${{ github.event_name }}"
5150
mkdir -p /tmp/ai-analysis-reports
52-
if [ "${{ github.event_name }}" = "pull_request" ]; then
53-
# For pull requests, compare against the base branch
54-
BASE_REF="${{ github.event.pull_request.base.ref }}"
55-
echo "Base ref: $BASE_REF"
56-
git diff --name-only "origin/$BASE_REF"...HEAD > /tmp/ai-analysis-reports/changed_files.txt 2>/dev/null
57-
else
58-
# For pushes, compare against the previous commit or get all JSON files if it's the first commit
59-
git diff --name-only HEAD~1 HEAD > /tmp/ai-analysis-reports/changed_files.txt 2>/dev/null
60-
fi
51+
BASE_REF="${{ github.event.pull_request.base.ref }}"
52+
git fetch origin $BASE_REF
53+
echo "Base ref: $BASE_REF"
54+
# List only Added (A) or Modified (M) JSON files
55+
git diff --name-only --diff-filter=AM "origin/$BASE_REF"...HEAD \
56+
| grep '\.json$' > /tmp/ai-analysis-reports/changed_files.txt 2>/dev/null
6157
echo "Changed JSON files:"
6258
cat /tmp/ai-analysis-reports/changed_files.txt
6359

0 commit comments

Comments
 (0)