Make Money Online AUTOMATION Python Automation | Part 11 : GitHub Automation using Python | Python Selenium Web Automation

Python Automation | Part 11 : GitHub Automation using Python | Python Selenium Web Automation

Python Automation | Part 11 : GitHub Automation using Python | Python Selenium Web Automation post thumbnail image


In this article, we are going to automate the process of creating a new repository on GitHub and then pushing our code to it. We will be using Python Selenium Web Automation for this.

First, we need to install the selenium and python-git packages.

sudo pip install selenium sudo pip install python-git

Now, we need to create a file called github_automation.py and add the following code to it.

import selenium import time from git import Repo, Branch, Remote, Status, Logger, Error import os # Set the username and password for your GitHub account username = “username” password = “password” # The name of the repository to create repo_name = “python-automation” # The branch to create branch_name = “master” # The remote to use remote = “origin” # The name of the file to push to the repository file_name = “test.py” # The status of the repository status = “initial” # The logger logger = Logger() # Connect to GitHub selenium.start() # Create the repository on GitHub repo = Repo(username, password, repo_name, branch_name, remote) # Push the code to the repository repo.push(file_name, status) # Print the log of the push operation logger.info(repo.log)

Now, let’s run the script.

python github_automation.py

This will create a new repository on GitHub called python-automation and push our code to it. You can also specify the branch and remote name if you want.

Related Post