File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 /
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff line change 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 <krishnadhasnk1997@gmail.com>" ]
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"
You can’t perform that action at this time.
0 commit comments