proper GH variable setting

This commit is contained in:
pseusys
2023-02-26 10:27:24 +01:00
parent e23ce9dc4b
commit 1d90aba35c
2 changed files with 6 additions and 3 deletions

View File

@@ -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}")

View File

@@ -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