github_actions.py 776 B

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