Skip to content

devwithkrishna/automation-to-add-repos-to-a-github-app

Repository files navigation

automation-to-add-repos-to-a-github-app

create an automation to add repos to a github app

Credentials used for authorization

credential purpose check
fine grained personal access token this is used for all purpose like listing repos, github app detailsetc ✔️
personal access token classic this is used for api call to add repos to github app ✔️

personal access token classic - provide all repo access Screenshot_3-5-2024_234236_github com

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