Skip to content

Commit cd154d4

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

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,26 @@ jobs:
4848
- name: Get changed files
4949
run: |
5050
mkdir -p /tmp/ai-analysis-reports
51+
52+
# Upstream repo (base repository)
53+
UPSTREAM_REPO="${{ github.event.pull_request.base.repo.full_name }}"
5154
BASE_REF="${{ github.event.pull_request.base.ref }}"
52-
git fetch origin $BASE_REF
55+
echo "Upstream repo: $UPSTREAM_REPO"
5356
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
57+
58+
# Add upstream remote and fetch latest base branch
59+
git remote add upstream "https://github.com/$UPSTREAM_REPO.git"
60+
git fetch upstream $BASE_REF
61+
62+
# Checkout PR code
63+
git checkout ${{ github.event.pull_request.head.ref }}
64+
65+
# Diff fork PR vs upstream base branch
66+
git diff --name-only --diff-filter=AM upstream/$BASE_REF...HEAD \
67+
| grep -E '\.json$' > /tmp/ai-analysis-reports/changed_files.txt || true
68+
5769
echo "Changed JSON files:"
58-
cat /tmp/ai-analysis-reports/changed_files.txt
70+
cat /tmp/ai-analysis-reports/changed_files.txt || echo "(none)"
5971
6072
- name: Run AI analysis
6173
env:

0 commit comments

Comments
 (0)