0

I am trying to write a script to update the contents of a file in a GitHub repo. I have a File.txt that has the required data.

Here's the code I've written

from github import Github
g = Github(ACCESS_TOKEN)
repo = g.get_repo(REPO_NAME)
contents = repo.get_contents("GITHUB_FILE_PATH")
repo.update_file(contents.path, "COMMIT_MSG", "NEW_CONTENT", contents.sha, branch = BRANCH_NAME)

Is there a way I can pass File.txt as the NEW_CONTENT parameter so that the content of the github file is replaced by content of File.txt?

0 Answers0