Skip to content

Commit 10a9b21

Browse files
committed
Ensure we get the right diff to update knowledge base
1 parent 890dd0c commit 10a9b21

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/update-docs-prod.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
steps:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Fetch all history so we can compare commits
1416

1517
- name: Set up Python
1618
uses: actions/setup-python@v4
@@ -27,5 +29,6 @@ jobs:
2729
FIRESTORE_PROJECT_ID: ${{ secrets.PROD_FIRESTORE_PROJECT_ID }}
2830
FIRESTORE_CREDENTIALS_JSON: ${{ secrets.PROD_FIRESTORE_CREDENTIALS_JSON }}
2931
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
32+
GITHUB_BASE_SHA: ${{ github.event.before }}
3033
run: |
3134
python update_docs.py --mode incremental

update_docs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ def get_file_hash(file_path: str) -> Optional[str]:
4343
def get_git_changed_files() -> Tuple[List[str], List[str], bool]:
4444
"""Get changed files using Git diff. Returns (changed_files, new_files, git_success)."""
4545
try:
46-
print("🔍 Comparing against base branch: origin/main")
46+
# When running in CI, use the GITHUB_BASE_SHA if available (set by workflow)
47+
# Otherwise, compare with origin/main for local development
48+
base_ref = os.getenv('GITHUB_BASE_SHA', 'origin/main')
49+
print(f"🔍 Comparing against: {base_ref}")
4750

48-
# Get all files changed since origin/main
51+
# Get all files changed since base_ref
4952
result = subprocess.run(
50-
['git', 'diff', '--name-only', 'origin/main', 'HEAD'],
53+
['git', 'diff', '--name-only', base_ref, 'HEAD'],
5154
capture_output=True,
5255
text=True,
5356
cwd=os.getcwd()

0 commit comments

Comments
 (0)