-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_project_id.py
More file actions
executable file
·94 lines (77 loc) · 2.55 KB
/
get_project_id.py
File metadata and controls
executable file
·94 lines (77 loc) · 2.55 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
"""
Script to get GitHub Project ID for PlanB-Network organization
"""
import requests
import json
from config import Config
def get_project_id(token):
"""Get all projects from PlanB-Network organization"""
query = """
query {
organization(login: "PlanB-Network") {
projectsV2(first: 20) {
nodes {
id
title
number
url
closed
}
}
}
}
"""
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json',
}
response = requests.post(
'https://api.github.com/graphql',
json={'query': query},
headers=headers
)
if response.status_code != 200:
print(f"Error: {response.status_code}")
print(response.text)
return
data = response.json()
if 'errors' in data:
print("GraphQL Errors:")
for error in data['errors']:
print(f" - {error['message']}")
return
projects = data['data']['organization']['projectsV2']['nodes']
print("\nPlanB-Network Projects:")
print("-" * 80)
for project in projects:
status = "✓ Open" if not project['closed'] else "✗ Closed"
print(f"\nTitle: {project['title']}")
print(f"Number: #{project['number']}")
print(f"ID: {project['id']}")
print(f"URL: {project['url']}")
print(f"Status: {status}")
print("-" * 40)
# Look for proofreading project
print("\n🔍 Looking for Proofreading project...")
for project in projects:
if 'proofreading' in project['title'].lower():
print(f"\n✅ Found Proofreading Project!")
print(f" Title: {project['title']}")
print(f" ID: {project['id']}")
print(f"\n Add this to your .env file:")
print(f" GITHUB_PROJECT_ID={project['id']}")
return project['id']
print("\n⚠️ No project with 'Proofreading' in the title found.")
print(" Please check the project list above and manually select the correct ID.")
if __name__ == "__main__":
# Try to get token from environment or config
token = Config.GITHUB_TOKEN
if not token:
print("Please enter your GitHub Personal Access Token:")
print("(The token needs 'repo' and 'project' permissions)")
token = input("Token: ").strip()
if not token:
print("Error: No token provided")
exit(1)
get_project_id(token)