Skip to content

Commit 1882cc6

Browse files
Initial commit
1 parent a654aa4 commit 1882cc6

File tree

5 files changed

+229
-2
lines changed

5 files changed

+229
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ cython_debug/
157157
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/
160+
.idea/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# guthub-create-and-add-labels-all-repos-using-python
2-
Create and add GitHub labels to repositories which can be later used for pull requests and issuead
2+
Create and add GitHub labels to repositories which can be later used for pull requests and issues

create_new_labels.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import requests
3+
from dotenv import load_dotenv
4+
5+
def list_repos_in_org(org_name: str):
6+
"""
7+
list all repos in github organization
8+
:param org_name:
9+
:return:
10+
"""
11+
# GitHub endpoint for listing repos under an organization
12+
repo_url = f"https://api.github.com/orgs/{org_name}/repos"
13+
# print(f"github api endpoint url {repo_url}")
14+
15+
headers = {
16+
"Accept": "application/vnd.github+json",
17+
"Authorization": f"Bearer {os.getenv('GH_TOKEN')}",
18+
"X-GitHub-Api-Version": "2022-11-28"
19+
}
20+
21+
response = requests.get(url=repo_url, headers=headers)
22+
response_json = response.json()
23+
print(response_json)
24+
25+
def main():
26+
""" To test the script"""
27+
load_dotenv()
28+
org_name = os.getenv('ORGANIZATION')
29+
list_repos_in_org(org_name=org_name)
30+
31+
if __name__ == "__main__":
32+
main()

poetry.lock

Lines changed: 179 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[tool.poetry]
2+
name = "github-create-and-add-labels-all-repos-using-python"
3+
version = "0.1.0"
4+
description = "Create and add GitHub labels to repositories which can be later used for pull requests and issues"
5+
authors = ["githubofkrishnadhas <[email protected]>"]
6+
readme = "README.md"
7+
8+
[tool.poetry.dependencies]
9+
python = "^3.10"
10+
requests = "^2.32.3"
11+
python-dotenv = "^1.0.1"
12+
13+
14+
[build-system]
15+
requires = ["poetry-core"]
16+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)