-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from jannekem/utilities
Add utility functions
- Loading branch information
Showing
7 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
node_modules/ | ||
venv/ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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): | ||
print(f"::set-output name={name}::{_escape_data(value)}") | ||
|
||
|
||
def set_env(name, value): | ||
with open(os.getenv("GITHUB_ENV"), "a") as env: | ||
print(f"{name}={_escape_data(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): | ||
print(f"::save-state name={name}::{_escape_data(value)}") | ||
|
||
|
||
def _escape_data(value: str): | ||
return value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters