-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutil.py
More file actions
70 lines (38 loc) · 1.38 KB
/
util.py
File metadata and controls
70 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
def add_path(path):
with open(os.getenv("GITHUB_PATH"), "a") as github_path:
print(path, file=github_path)
def get_input(name):
return os.getenv(f"INPUT_{name}".upper())
def set_output(name, value):
with open(os.getenv("GITHUB_OUTPUT"), "a") as env:
print(f"{name}={_escape_data(value)}", file=env)
def set_env(name, value):
with open(os.getenv("GITHUB_ENV"), "a") as env:
print(f"{name}={_escape_data(value)}", file=env)
def set_summary(value):
with open(os.getenv("GITHUB_STEP_SUMMARY"), "a") as env:
print(value, file=env)
def debug(message):
print(f"::debug::{_escape_data(message)}")
def warning(message):
print(f"::warning::{_escape_data(message)}")
def error(message):
print(f"::error::{_escape_data(message)}")
def group(title):
print(f"::group::{title}")
def end_group():
print(f"::endgroup::")
def add_mask(value):
print(f"::add-mask::{_escape_data(value)}")
def stop_commands():
print(f"::stop-commands::pause-commands")
def resume_commands():
print(f"::pause-commands::")
def get_state(name):
return os.getenv(f"STATE_{name}")
def save_state(name, value):
with open(os.getenv("GITHUB_STATE"), "a") as env:
print(f"{name}={_escape_data(value)}", file=env)
def _escape_data(value: str):
return value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")