File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222from blog .pipeline_cache import write_cache , emit_gha_warnings # noqa: E402
2323
2424
25+ def env_int (name : str , default : int ) -> int :
26+ raw = os .environ .get (name , "" ).strip ()
27+ if not raw :
28+ return default
29+ try :
30+ return int (raw )
31+ except ValueError :
32+ print (f"::warning::{ name } ={ raw !r} is not a valid integer; using { default } ." )
33+ return default
34+
35+
2536def main () -> None :
2637 repo = os .environ .get ("GITHUB_REPOSITORY" , "" ).strip ()
2738 if not repo :
@@ -30,7 +41,7 @@ def main() -> None:
3041
3142 user = os .environ .get ("GITHUB_CONTRIBUTIONS_USER" , "" ).strip () or repo .split ("/" )[0 ]
3243 token = os .environ .get ("GITHUB_TOKEN" ) or None
33- limit = int ( os . environ . get ( "GITHUB_CONTRIBUTIONS_LIMIT" , "8" ) )
44+ limit = env_int ( "GITHUB_CONTRIBUTIONS_LIMIT" , 8 )
3445
3546 print (f"Fetching GitHub contributions for: { user } …" )
3647 start = time .monotonic ()
You can’t perform that action at this time.
0 commit comments