"""Check whether the Hugging Face deployment token is available.""" from __future__ import annotations import os from pathlib import Path TOKEN_ENV_VAR = "HF_BUILD_SMALL_HACKATHON_TOKEN" def main() -> None: """Emit a GitHub Actions output instead of raising KeyError for a missing token.""" token = os.environ.get(TOKEN_ENV_VAR, "").strip() available = "true" if token else "false" github_output = os.environ.get("GITHUB_OUTPUT") if github_output: with Path(github_output).open("a", encoding="utf-8") as output_file: output_file.write(f"available={available}\n") if token: print(f"{TOKEN_ENV_VAR} is configured; Hugging Face Space deployment can continue.") return print( f"::warning::{TOKEN_ENV_VAR} is not configured. " "Skipping Hugging Face Space deployment instead of failing with KeyError." ) if __name__ == "__main__": main()