Skip to content

Commit f639fe6

Browse files
sync_metadata: embed generated_sha in index.json (tier-1 without api.github.com)
GitHub Actions sets GITHUB_SHA to the commit that triggered the run; surface it in index.json so consumers can do tier-1 early-exit via raw.githubusercontent.com only — no dependency on api.github.com, which is IPv4-only and unreachable from IPv6-first hosts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 29a6708 commit f639fe6

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

scripts/sync_metadata.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,24 @@ def main() -> int:
201201

202202
# index.json — cheap change-detection manifest.
203203
#
204-
# Consumers with a previously-synced state can avoid even fetching
205-
# this index: call `GET /repos/<owner>/<this-repo>/commits/<branch>`
206-
# first to get the current HEAD SHA, compare to the last-synced SHA,
207-
# and if different call `GET /compare/<last>...<head>` for a
208-
# file-level diff limited to metadata/. See README §Delta sync.
209-
repo_slug = os.environ.get("GITHUB_REPOSITORY", "")
204+
# `generated_sha` captures the commit SHA of the workflow run that
205+
# produced this index. Consumers use it as a Tier-1 early-exit
206+
# (stored value == current value → nothing changed, one HTTP request
207+
# total). Sourced from the GH Action's $GITHUB_SHA so the check
208+
# never has to hit api.github.com — important because GitHub's REST
209+
# API is IPv4-only and many IPv6-first hosts can't reach it.
210+
repo_slug = os.environ.get("GITHUB_REPOSITORY", "")
211+
generated_sha = os.environ.get("GITHUB_SHA", "")
210212
index_doc = {
211-
"schema": "vyges-ip-catalog/index-v1",
212-
"generated_at": now,
213-
"repo": repo_slug,
214-
"org": args.org,
215-
"repo_count": len(repos),
213+
"schema": "vyges-ip-catalog/index-v1",
214+
"generated_at": now,
215+
"generated_sha": generated_sha,
216+
"repo": repo_slug,
217+
"org": args.org,
218+
"repo_count": len(repos),
216219
"with_metadata": len(have_metadata),
217220
"without_metadata": len(no_metadata),
218-
"ips": index_entries,
221+
"ips": index_entries,
219222
}
220223
index_text = json.dumps(index_doc, indent=2) + "\n"
221224
index_changed = write_if_changed(out / "index.json", index_text)

0 commit comments

Comments
 (0)