from github.env import exit_on_error_and_write_summary, get_required_env_var, write_github_env, write_github_summary
from actions_logging.app_logging import logger
from collections import Counter
from github.github_apis import get_repo_runtime

def main():
    try:
        repo = get_required_env_var('GITHUB_REPOSITORY')
        language = get_repo_runtime(repo)
        match language:
            case "Java":
                    write_github_env(language, "RUNTIME")
            case "JavaScript" | "TypeScript":
                    write_github_env("Node", "RUNTIME")
            case "Go":
                    write_github_env(language, "RUNTIME")
            case _:
                    raise RuntimeError(f"Detected unsupported repository language: {language}")
    except Exception as e:
        exit_on_error_and_write_summary(f"Error on assigning runtime: {e}")

if __name__ == "__main__":
    main()
