diff --git a/projects/Build-Github-Bot-With-Python/Build-Github-Bot-With-Python.mdx b/projects/Build-Github-Bot-With-Python/Build-Github-Bot-With-Python.mdx new file mode 100644 index 00000000..521504c6 --- /dev/null +++ b/projects/Build-Github-Bot-With-Python/Build-Github-Bot-With-Python.mdx @@ -0,0 +1,62 @@ +--- +title: Build Github Bot With Python +author: Neel Chetankumar Shah +datePublished: 2022-10-31 +description: A github bot to automate some features. +tags: + - medium + - python + - automation +--- + +# Github Bot + + + +![Header image](https://user-images.githubusercontent.com/71593494/201167578-f78dd638-4dcc-4d4d-bbd9-37c594d92f55.png +) + +**Prerequisites:** Python +**Versions:** 3.10 +**Read Time:** 2 minutes + +## [#](#-introduction) Introduction + + Here using github library we had done some tasks as below: +- printing all repositories related to a specific langauge +- viewing all repositories of user account +- login on github +- view number of stars of a spefic repository +- create repository on github using python +- push files ina repositroy using python +- delete file in a repository + + + + List out the libraries imported->github + + +## Workflow of the Project + +First we need to install github library then we just need to run the script and perform the tasks. + + +## Setup instructions +For setup we need to have github username and password with us and we need to provide it in the script , then we can perform task as per our requirement. + + + + +## Output +- Getting all python repos +![image](Image/output_1(git).png) + +- making sample repo +![image](Image/output_2(git).png) + +- making sample file +![image](Image/output_3(git).png) + + + + diff --git a/projects/Build-Github-Bot-With-Python/Image/Readme.md b/projects/Build-Github-Bot-With-Python/Image/Readme.md new file mode 100644 index 00000000..c25a7efc --- /dev/null +++ b/projects/Build-Github-Bot-With-Python/Image/Readme.md @@ -0,0 +1 @@ +It has images of the bot. diff --git a/projects/Build-Github-Bot-With-Python/Image/output_1(git).png b/projects/Build-Github-Bot-With-Python/Image/output_1(git).png new file mode 100644 index 00000000..9be8978c Binary files /dev/null and b/projects/Build-Github-Bot-With-Python/Image/output_1(git).png differ diff --git a/projects/Build-Github-Bot-With-Python/Image/output_2(git).png b/projects/Build-Github-Bot-With-Python/Image/output_2(git).png new file mode 100644 index 00000000..b6cdf906 Binary files /dev/null and b/projects/Build-Github-Bot-With-Python/Image/output_2(git).png differ diff --git a/projects/Build-Github-Bot-With-Python/Image/output_3(git).png b/projects/Build-Github-Bot-With-Python/Image/output_3(git).png new file mode 100644 index 00000000..c50ba8ea Binary files /dev/null and b/projects/Build-Github-Bot-With-Python/Image/output_3(git).png differ diff --git a/projects/Build-Github-Bot-With-Python/github_bot.py b/projects/Build-Github-Bot-With-Python/github_bot.py new file mode 100644 index 00000000..81ccb860 --- /dev/null +++ b/projects/Build-Github-Bot-With-Python/github_bot.py @@ -0,0 +1,32 @@ +from github import Github +#user login +g=Github("username","password") + + +#showing all the repositories of python +repos= g.search_repositories(query="language:python") +for i in repos: + print(i) + +#for getting all the repos of user +for repo in g.get_user().get_repos(): + print(repo.name) + +#shows the no. of star of the repo +repo=g.get_repo("repository name") +repo.stargazers_count + +#getting all the contents of particular repo +content=repo.get_contents("") +for content_fil in content: + print(content_fil) + +#making a repo test and creating test file +user= g.get_user() +repo=user.create_repo('test') +repo.create_file("test.txt","commit","hello coders") + +#deleting file from the repo +repo=g.get_repo("")#enter repository name inside the bracket +cont=repo.get_contents("test.txt") +repo.delete_file(cont.path,"remove test",cont.sha,branch='master') \ No newline at end of file