Manage a large amount of GitHub repositories at once.
Install requirements:
pip3 install -r requirements.txt-
Pick an action from
actions/ -
Fill out
config.yml. See Config Files for details. -
Set up how you're authenticating with GitHub
-
Run
./git-manager {ACTION DIR}Example:
./git-manager ./actions/add-file-static
# List orgs and repos here
orgs:
your_org1:
repos:
- repo1
- repo2
your_org2:
repos: [repo1, repo2]
# General required configs here
general:
branch:
branch_name:
create_branch:
commit:
git_add:
commit_message:
pull_request:
create_pr:
title:
body:
base:
remove_repo:
remove_tmp_dir:
# Variables needed in action file
extra_vars:orgs - List of GitHub organizations or users that own the repositories
repos- List of repositories to be managed
general - General configuration details
-
branchbranch_name- The name of the branch to be worked on during runtime
create_branchyesornoto create a branch withbranch_name- Use if the branch doesn't already exist.
-
commitgit_add- List of files to
git addto the commit - Example:
git_add: - CONTRIBUTING.md - .github/ISSUE_TEMPLATE/bug.md- List of files to
commit_message- The title of the commit
-
pull_requestcreate_pryesornoto create a pull request frombranch_nametobaseon each repo- Requires GitHub Authentication
- Auth Token requires correct privileges
title- Title of the pull request
body- Body description of the pull request
- Not a required parameter
base- Base branch to make the pull request point towards
masterin most cases
-
remove_repoyesornoto remove each repo locally, after pusing the changes- Helpful if changing a lot of repos and storage space is an issue
-
remove_tmp_diryesornoto remove the temporary directory after completion
extra_vars - List of action specific variables
There are two ways to set up your local environment to run the script, but either way you'll need a GitHub account and a personal access token. If the organizations that own the repos you are managing use SAML single sign-on(SSO), make sure to authorize your personal access token.
-
Set the following environment variables:
GITHUB_USERNAMEGITHUB_AUTH_TOKEN -
To start, run
./git-manager {ACTION DIR}
-
You can store your GitHub auth token in your OSX keyring and run this script using Summon and the keyring provider.
To do this, add your auth token to your keyring by running:
security add-generic-password \ -s "summon" \ -a "github/api_token" \ -w "[ACCESS TOKEN]"
-
Update
secrets.ymlto include your github username. -
To start, run
summon -p keyring.py ./git-manager {ACTION DIR}
The script requires an action directory to be specified on startup. An action directory consists of, at the very minimum,
a config.yml and an action script. Any other files necessary to the specific action should be kept in this directory.
The action script must be able to be executed with ./path/action.
git-manager passes the path to the current repo to action by setting the GIT_MANAGER_CURR_REPO environment
variable, before calling the action.