{"id":16504985,"url":"https://github.com/sgibson91/github-commits-over-api","last_synced_at":"2025-08-01T00:02:51.230Z","repository":{"id":37929092,"uuid":"408525169","full_name":"sgibson91/github-commits-over-api","owner":"sgibson91","description":"A demo repo showing how you can make commits to GitHub over the API in Python","archived":false,"fork":false,"pushed_at":"2023-09-20T10:50:49.000Z","size":83,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T12:39:45.722Z","etag":null,"topics":["api","commit","git","github","python"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgibson91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-20T16:49:14.000Z","updated_at":"2022-08-18T14:49:01.000Z","dependencies_parsed_at":"2025-01-12T12:36:21.190Z","dependency_job_id":"a741b482-03ff-49bc-bced-6f5386329b09","html_url":"https://github.com/sgibson91/github-commits-over-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgibson91%2Fgithub-commits-over-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgibson91%2Fgithub-commits-over-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgibson91%2Fgithub-commits-over-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgibson91%2Fgithub-commits-over-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgibson91","download_url":"https://codeload.github.com/sgibson91/github-commits-over-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241435141,"owners_count":19962401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","commit","git","github","python"],"created_at":"2024-10-11T15:08:37.769Z","updated_at":"2025-03-01T22:56:49.788Z","avatar_url":"https://github.com/sgibson91.png","language":null,"readme":"# Committing files over the GitHub API with Python\n\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sgibson91/github-commits-over-api/main.svg)](https://results.pre-commit.ci/latest/github/sgibson91/github-commits-over-api/main)\n\nThis is a demo repo where I was testing making commits over the GitHub API using Python and the `requests` library.\nI've found this method useful when automating tasks that involve interacting with the GitHub API.\nIt removes the need to have `git` installed in the environment your process is running in, and removes the need to clone the repository locally for the sake of editing one or two files.\n\nAll code can be found in the [`examples` folder](./examples).\nThe requirements for the code can be installed by running\n\n```bash\npip install -r requirements.txt\n```\n\nTo run these examples, you will need to [create a Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) (the `public_repo` scope should be adequate) and add it to your bash environment.\n\n```bash\nexport GITHUB_TOKEN=\"PASTE YOUR TOKEN HERE\"\n```\n\nEach example script requires the repo to interact with, in the form `user/repo`, and the path to the file to edit relative to the root of the repo, e.g.:\n\n```bash\npython examples/\u003cSCRIPT_NAME\u003e sgibson91/github-commits-over-api README.md\n```\n\nSome of the more complex workflow examples may require additional inputs.\nYou can get the help for each example by running\n\n```bash\npython examples/\u003cSCRIPT_NAME\u003e --help\n```\n\n### The Examples\n\n- [`1_commit.py`](examples/1_commit.py): My first attempt, largely following this blog: \u003chttp://www.levibotelho.com/development/commit-a-file-with-the-github-api/\u003e\n- [`2_commit-simple.py`](examples/2_commit-simple.py): Then I found a shortcut for all the blob and tree stuff which reduced the number of steps/API calls required\n- [`3_branch-commit-pr.py`](examples/3_branch-commit-pr.py): Replicates the workflow of creating a branch, committing to it and opening a Pull Request\n- [`4_fork-branch-commit-pr.py`](examples/4_fork-branch-commit-pr.py): Replicates the workflow of forking the repo, creating a branch, committing to the branch, and opening a Pull Request back to the original repo\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgibson91%2Fgithub-commits-over-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgibson91%2Fgithub-commits-over-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgibson91%2Fgithub-commits-over-api/lists"}