-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
61 lines (51 loc) · 1.69 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import sys
from github import Github
from dotenv import load_dotenv
load_dotenv()
# Check arguments and OS ENV
if len(sys.argv) > 1:
if len(sys.argv) == 3:
repository_owner = sys.argv[1]
repository_name = sys.argv[2]
labels = sys.argv[3].split(",")
else:
print("Error: Invalid number of arguments")
sys.exit(1)
else:
repository_owner = os.getenv("REPO_OWNER")
repository_name = os.getenv("REPO_NAME")
labels = os.getenv("LABELS")
if labels:
labels = labels.split(",")
else:
print("Error: No labels provided")
sys.exit(1)
# Replace with your GitHub access token
ACCESS_TOKEN = os.getenv("ACCESS_TOKEN")
# Create a GitHub instance using the access token
g = Github(ACCESS_TOKEN)
# Get the repository object
print(repository_owner)
print(repository_name)
repo = g.get_repo(f"{repository_owner}/{repository_name}")
# Get all the issues in the repository with the "auto-release" label
state = "open"
issues = repo.get_issues(labels=labels, state=state, sort='updated')
# Log repository
print(repo)
# Loop through each issue and get its comments
for issue in issues:
print(f"Issue: {issue.title}")
print("body: <<<", issue.body, ">>>")
comments = list(issue.get_comments()).reverse()
comments = issue.get_comments()
if comments.totalCount > 0:
# reverse iterate over comments
for i in range(comments.totalCount - 1, -1, -1):
print("------------------------")
print(comments[i].body)
print("------------------------")
else:
print("No comments in this issue")
print("\n\n")