Skip to content

Commit ac45c00

Browse files
committed
Add another script for alpha
1 parent 7afb50b commit ac45c00

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy to Alpha Firestore
2+
3+
on:
4+
push:
5+
branches: [ anusha/pinecone-github-actions ]
6+
7+
jobs:
8+
deploy-alpha:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.9'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -r requirements.txt
24+
25+
- name: Deploy to Alpha Firestore
26+
env:
27+
FIRESTORE_PROJECT_ID: ${{ secrets.ALPHA_FIRESTORE_PROJECT_ID }}
28+
FIRESTORE_CREDENTIALS_JSON: ${{ secrets.ALPHA_FIRESTORE_CREDENTIALS_JSON }}
29+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
30+
run: |
31+
python update_docs.py --mode incremental
32+
File renamed without changes.

update_docs.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class Config:
1515
"""Configuration constants for the documentation updater."""
1616
REPO_FOLDER = "./docs"
17-
STATE_FILE = "docs_state.json"
1817
MAX_CHUNK_SIZE = 500
1918
BATCH_SIZE = 50
2019
DELETE_BATCH_SIZE = 20
@@ -28,6 +27,25 @@ class Config:
2827
# OpenAI Configuration
2928
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
3029
OPENAI_EMBEDDING_MODEL = "text-embedding-3-small"
30+
31+
@classmethod
32+
def get_state_file(cls) -> str:
33+
"""Get environment-specific state file name."""
34+
project_id = cls.FIRESTORE_PROJECT_ID
35+
if not project_id:
36+
return "docs_state_dev.json" # fallback to dev state file
37+
38+
# Extract environment from project ID (assuming naming convention like dreamflow-docs-dev, dreamflow-docs-alpha, dreamflow-docs-prod)
39+
if "dev" in project_id.lower():
40+
return "docs_state_dev.json"
41+
elif "alpha" in project_id.lower():
42+
return "docs_state_alpha.json"
43+
elif "prod" in project_id.lower():
44+
return "docs_state_prod.json"
45+
else:
46+
# Use project ID as suffix for other environments
47+
safe_project_id = project_id.replace("-", "_").replace(".", "_")
48+
return f"docs_state_{safe_project_id}.json"
3149

3250

3351
def get_file_hash(file_path: str) -> Optional[str]:
@@ -41,9 +59,10 @@ def get_file_hash(file_path: str) -> Optional[str]:
4159

4260
def load_file_state() -> Dict[str, Dict[str, str]]:
4361
"""Load previous file states for change detection."""
44-
if os.path.exists(Config.STATE_FILE):
62+
state_file = Config.get_state_file()
63+
if os.path.exists(state_file):
4564
try:
46-
with open(Config.STATE_FILE, 'r') as f:
65+
with open(state_file, 'r') as f:
4766
return json.load(f)
4867
except (json.JSONDecodeError, IOError):
4968
return {}
@@ -52,13 +71,16 @@ def load_file_state() -> Dict[str, Dict[str, str]]:
5271

5372
def save_file_state(state: Dict[str, Dict[str, str]]) -> None:
5473
"""Save current file states."""
55-
with open(Config.STATE_FILE, 'w') as f:
74+
state_file = Config.get_state_file()
75+
print(f"💾 Saving state to: {state_file}")
76+
with open(state_file, 'w') as f:
5677
json.dump(state, f, indent=2)
5778

5879

5980
def get_changed_files() -> Tuple[List[str], List[str], Dict[str, str]]:
6081
"""Detect which files have changed since last run."""
61-
print("🔍 Detecting changed files...")
82+
state_file = Config.get_state_file()
83+
print(f"🔍 Detecting changed files using state file: {state_file}")
6284

6385
previous_state = load_file_state()
6486
current_hashes = {}

0 commit comments

Comments
 (0)