pytorch/.github/scripts/parse_ref.py
PyTorch MergeBot 66658e1da7 Revert "[BE] Get rid of deprecation warnings in workflows (#87152)"
This reverts commit acaf484f0a.

Reverted https://github.com/pytorch/pytorch/pull/87152 on behalf of https://github.com/malfet due to Regresses is_pr_labelled workflow
2022-10-18 04:14:01 +00:00

21 lines
526 B
Python
Executable file

#!/usr/bin/env python3
import os
import re
def main() -> None:
ref = os.environ['GITHUB_REF']
m = re.match(r'^refs/(\w+)/(.*)$', ref)
if m:
category, stripped = m.groups()
if category == 'heads':
print(f'::set-output name=branch::{stripped}')
elif category == 'pull':
print(f'::set-output name=branch::pull/{stripped.split("/")[0]}')
elif category == 'tags':
print(f'::set-output name=tag::{stripped}')
if __name__ == '__main__':
main()