mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Fix workflow for closing nonexistent disable issues (#146447)
The workflow could not update issues because it didn't have permissions, and it looked green because it didn't check return codes. Tested by running the workflow and seeing that issues did get closed Fixes https://github.com/pytorch/pytorch/issues/145382 Pull Request resolved: https://github.com/pytorch/pytorch/pull/146447 Approved by: https://github.com/huydhn
This commit is contained in:
parent
9b6d680131
commit
97b64f2e5c
|
|
@ -107,16 +107,20 @@ def close_issue(num: int) -> None:
|
|||
"Accept": "application/vnd.github.v3+json",
|
||||
"Authorization": f"token {os.environ['GITHUB_TOKEN']}",
|
||||
}
|
||||
requests.post(
|
||||
response = requests.post(
|
||||
f"https://api.github.com/repos/pytorch/pytorch/issues/{num}/comments",
|
||||
data=json.dumps({"body": CLOSING_COMMENT}),
|
||||
headers=headers,
|
||||
)
|
||||
requests.patch(
|
||||
if response.status_code != 201:
|
||||
raise RuntimeError(f"Failed to comment on issue {num}: {response.text}")
|
||||
response = requests.patch(
|
||||
f"https://api.github.com/repos/pytorch/pytorch/issues/{num}",
|
||||
data=json.dumps({"state": "closed"}),
|
||||
headers=headers,
|
||||
)
|
||||
if response.status_code != 200:
|
||||
raise RuntimeError(f"Failed to close issue {num}: {response.text}")
|
||||
|
||||
|
||||
def check_if_exists(
|
||||
|
|
@ -190,6 +194,13 @@ if __name__ == "__main__":
|
|||
if args.dry_run:
|
||||
print("dry run, not actually closing")
|
||||
else:
|
||||
failed = False
|
||||
for item in to_be_closed:
|
||||
_, (num, _, _) = item
|
||||
close_issue(num)
|
||||
try:
|
||||
close_issue(num)
|
||||
except RuntimeError as e:
|
||||
print(e)
|
||||
failed = True
|
||||
if failed:
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ on:
|
|||
jobs:
|
||||
close-nonexistent-disable-issues:
|
||||
environment: rockset-read-only
|
||||
permissions:
|
||||
issues: write
|
||||
if: github.repository_owner == 'pytorch'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user