-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae0a9a3
commit 26f50d2
Showing
1 changed file
with
30 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
|
||
# Replace these with your details | ||
GITHUB_TOKEN = "your_personal_access_token" | ||
REPO_OWNER = "Anjaliavv51" | ||
REPO_NAME = "Retro" | ||
|
||
# GitHub API URL | ||
API_URL = f"https://api.github.com/repos/Anjaliavv51/Retro/issues" | ||
|
||
# Set up headers for authentication | ||
headers = { | ||
"Authorization": f"token {GITHUB_TOKEN}", | ||
"Accept": "application/vnd.github+json" | ||
} | ||
|
||
# Fetch open issues | ||
response = requests.get(API_URL, headers=headers, params={"state": "open"}) | ||
if response.status_code == 200: | ||
issues = response.json() | ||
for issue in issues: | ||
issue_number = issue["number"] | ||
close_url = f"{API_URL}/{issue_number}" | ||
close_response = requests.patch(close_url, headers=headers, json={"state": "closed"}) | ||
if close_response.status_code == 200: | ||
print(f"Issue #{issue_number} closed.") | ||
else: | ||
print(f"Failed to close issue #{issue_number}: {close_response.status_code}") | ||
else: | ||
print(f"Failed to fetch issues: {response.status_code}") |