https://github.com/devwithkrishna/automation-to-add-repos-to-a-github-app
create an automation to add repos to a github app
https://github.com/devwithkrishna/automation-to-add-repos-to-a-github-app
github-automation github-repositories github-restapi githubapp python
Last synced: 4 months ago
JSON representation
create an automation to add repos to a github app
- Host: GitHub
- URL: https://github.com/devwithkrishna/automation-to-add-repos-to-a-github-app
- Owner: devwithkrishna
- License: mit
- Created: 2024-03-21T16:48:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-04T15:33:10.000Z (5 months ago)
- Last Synced: 2025-02-04T16:31:24.974Z (5 months ago)
- Topics: github-automation, github-repositories, github-restapi, githubapp, python
- Language: Python
- Homepage: https://github.com/devwithkrishna/automation-to-add-repos-to-a-github-app
- Size: 40 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# automation-to-add-repos-to-a-github-app
create an automation to add repos to a github app* Reference : [list-app-installations-for-an-organization](https://docs.github.com/en/rest/orgs/orgs?apiVersion=2022-11-28#list-app-installations-for-an-organization)
# Credentials used for authorization
| credential | purpose | check |
|------------|---------|--------------------|
| fine grained personal access token | this is used for all purpose like listing repos, github app detailsetc | :heavy_check_mark: |
| personal access token classic | this is used for api call to add repos to github app | :heavy_check_mark: |**personal access token classic - provide `all repo access`**
# parameters
| input name | type | description |
|------------|------|-------------|
| organization | string | Github organizarion name. Default - `devwithkrishna` |
| search-string | string | name of github repo starts with |
| github-app-name | string | name of github app to which repositories will be added |# How code works
* Based on the search string, the code will use the end point `https://api.github.com/orgs/{orgaization}/repos` to list all
repositories and get the ones matching. matching is done in a way that the seach string is considered as begining word of
Github repository name. - _list_repos_in_org.py_ & _list_github_app_matching_name.py_* Once its listed, later script pulls down all available github apps installed across the organization using the
endpoint `https://api.github.com/orgs/{organization}/installations` - _list_all_github_app_in_org.py_* Based on the Github app name provided as input it gathers the installation id. This is later used.
* using the matching repos based on search string and github app name provded, the script will use these details to the
endpoint `https://api.github.com/user/installations/{github_app_installation_id}/repositories/{repo_id}`. This uses
the personal access token classic to add repositories to github app - _add_a_repo_to_github_app.py_