Spaces:
Sleeping
Sleeping
File size: 931 Bytes
4713899 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | """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()
|