mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Print what the output that's getting set is for better debugging It's probably bad there are 4 of these, but I'm also not sure if imports will behave correctly Pull Request resolved: https://github.com/pytorch/pytorch/pull/157477 Approved by: https://github.com/huydhn
31 lines
776 B
Python
Executable File
31 lines
776 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import re
|
|
|
|
|
|
def set_output(name: str, val: str) -> None:
|
|
print(f"Setting output {name}={val}")
|
|
if os.getenv("GITHUB_OUTPUT"):
|
|
with open(str(os.getenv("GITHUB_OUTPUT")), "a") as env:
|
|
print(f"{name}={val}", file=env)
|
|
else:
|
|
print(f"::set-output name={name}::{val}")
|
|
|
|
|
|
def main() -> None:
|
|
ref = os.environ["GITHUB_REF"]
|
|
m = re.match(r"^refs/(\w+)/(.*)$", ref)
|
|
if m:
|
|
category, stripped = m.groups()
|
|
if category == "heads":
|
|
set_output("branch", stripped)
|
|
elif category == "pull":
|
|
set_output("branch", "pull/" + stripped.split("/")[0])
|
|
elif category == "tags":
|
|
set_output("tag", stripped)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|