mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
- Per [deprecation announcement](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) replace `echo "::set-output name="` with echo to `${GITHUB_OUTPUT}` as shown in following [example](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs#example-defining-outputs-for-a-job)
- Update `actions/setup-python` from `v2` to `v4` to get rid of deprecated node version warning
- Update `actions/checkout-python` from `v2` to `v3` (and `silent-checkout` branch as well)
- Update `retry` action to 3e91a01664
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87152
Approved by: https://github.com/kit1980, https://github.com/izaitsevfb
30 lines
734 B
Python
Executable File
30 lines
734 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import re
|
|
|
|
|
|
def set_output(name: str, val: str) -> None:
|
|
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()
|