From 1d90aba35c54bc9155ebc46855eff6e23f1e9abb Mon Sep 17 00:00:00 2001 From: pseusys Date: Sun, 26 Feb 2023 10:27:24 +0100 Subject: [PATCH] proper GH variable setting --- sources/manager_environment.py | 7 +++++-- sources/manager_github.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sources/manager_environment.py b/sources/manager_environment.py index a13b170..fe0930a 100644 --- a/sources/manager_environment.py +++ b/sources/manager_environment.py @@ -48,5 +48,8 @@ class EnvironmentManager: DEBUG_RUN = getenv("DEBUG_RUN", "False").lower() in _TRUTHY @staticmethod - def set_variable(name: str, content: str): - environ[name] = content + def set_github_output(name: str, content: str): + if "GITHUB_OUTPUT" not in environ.keys(): + raise Exception("Not in GitHub environment ('GITHUB_OUTPUT' not defined)!") + with open(environ["GITHUB_OUTPUT"], "a") as fh: + fh.write(f"{name}={content}") diff --git a/sources/manager_github.py b/sources/manager_github.py index 07340dc..8714c47 100644 --- a/sources/manager_github.py +++ b/sources/manager_github.py @@ -110,7 +110,7 @@ class GitHubManager: """ prefix = "README stats current output:" DBM.i("Commenting PR...") - EM.set_variable("GITHUB_OUTPUT", f"README_CONTENT={prefix}\n\n{stats}") + EM.set_github_output("README_CONTENT", f"{prefix}\n\n{stats}") DBM.g("PR commented!") @staticmethod