Skip to content

Commit

Permalink
Create codeforcloseofallissues.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjaliavv51 authored Dec 20, 2024
1 parent ae0a9a3 commit 26f50d2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions codeforcloseofallissues.py
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}")

0 comments on commit 26f50d2

Please sign in to comment.