|
62 | 62 | event_name = os.environ.get("GITHUB_EVENT_NAME", "") |
63 | 63 | ref_name = os.environ.get("GITHUB_REF_NAME", "") |
64 | 64 |
|
| 65 | + # Parse .alternates file: bidirectional map of filename → alternate slug |
| 66 | + alternates = {} |
| 67 | + alt_path = workspace / ".alternates" |
| 68 | + if alt_path.exists(): |
| 69 | + for line in alt_path.read_text(encoding="utf-8").splitlines(): |
| 70 | + line = line.strip() |
| 71 | + if not line or line.startswith("#"): |
| 72 | + continue |
| 73 | + parts = line.split("\t") |
| 74 | + if len(parts) == 2: |
| 75 | + a, b = parts[0].strip(), parts[1].strip() |
| 76 | + a_slug = pathlib.Path(a).stem.lower() |
| 77 | + b_slug = pathlib.Path(b).stem.lower() |
| 78 | + alternates[a] = b_slug |
| 79 | + alternates[b] = a_slug |
| 80 | + print(f"[debug] loaded {len(alternates)} alternate mappings") |
| 81 | +
|
65 | 82 | MAX_RETRIES = 3 |
66 | 83 | BASE_DELAY = 2 # seconds |
67 | 84 |
|
@@ -164,6 +181,9 @@ jobs: |
164 | 181 | "filename": rel_path, |
165 | 182 | "markdown": markdown, |
166 | 183 | } |
| 184 | + if rel_path in alternates: |
| 185 | + payload["alternate_filename"] = alternates[rel_path] |
| 186 | + print(f"[debug] alternate for {rel_path}: {alternates[rel_path]}") |
167 | 187 | data = json.dumps(payload).encode("utf-8") |
168 | 188 | req = urllib.request.Request( |
169 | 189 | endpoint, |
@@ -209,6 +229,9 @@ jobs: |
209 | 229 | "filename": rel_path, |
210 | 230 | "markdown": markdown, |
211 | 231 | } |
| 232 | + if rel_path in alternates: |
| 233 | + payload["alternate_filename"] = alternates[rel_path] |
| 234 | + print(f"[debug] alternate for {rel_path}: {alternates[rel_path]}") |
212 | 235 | data = json.dumps(payload).encode("utf-8") |
213 | 236 | req = urllib.request.Request( |
214 | 237 | endpoint, |
|
0 commit comments