master
py 27 lines 776 Bytes
Raw
1 import os
2
3
4 def update_github_env(key, value):
5 try:
6 env_file = os.getenv('GITHUB_ENV')
7 print(env_file)
8 with open(env_file, "a") as file:
9 file.write(f"{key}={value}")
10 print(f"Updated GITHUB_ENV with {key}={value}")
11 except Exception as e:
12 print(f"Error updating GITHUB_ENV. Error: {e}")
13
14
15 def update_github_output(key, value):
16 try:
17 env_file = os.getenv('GITHUB_OUTPUT')
18 print(env_file)
19 with open(env_file, "a") as file:
20 file.write(f"{key}={value}")
21 print(f"Updated GITHUB_OUTPUT with {key}={value}")
22 except Exception as e:
23 print(f"Error updating GITHUB_OUTPUT. Error: {e}")
24
25
26 def run_as_github_action():
27 return os.environ.get('GITHUB_ACTIONS') == 'true'