Skip to content
Kirill edited this page Apr 15, 2021 · 8 revisions

The gitstrap project aims to automate routine operations with GitHub such as managing repositories, organizations, teams, web-hooks and other resources. Each resource is represented as a yaml specification document that could be fetched from an existing resource or created from scratch. Each document can be updated and the specification resource configuration can be applied using CLI gitstrap tool.

The full specification format can be found here: /specifications

Tutorial

  1. Download and install
  2. Configuration
  3. CLI overview
  4. Basic examples

Download and install

For Linux system you can use download script to get latest binary:

curl -L https://raw.githubusercontent.com/g4s8/gitstrap/master/scripts/download.sh | sh

This script downloads gistrap CLI into ./gitstrap/ path of current directory. The binary could be copied to any of $PATH directories.

On MacOS it can be installed using HomeBrew:

brew tap g4s8/.tap https://github.com/g4s8/.tap
brew install g4s8/.tap/gitstrap

On any system (including Windows) the CLI binary can be found at releases page.

Alternatively, it can be built from sources (you'll need git, make and go installed on the system):

git clone --depth=1 https://github.com/g4s8/gitstrap.git
cd gitstrap
make build
sudo make install

Configuration

To use gitstrap CLI you need GitHub token. Some features depend on optional permissions:

  • repo - required
  • admin:org - to manage organizations
  • admin:org_hook - to manage organization web-hooks
  • delete_repo - to delete repositories

A new token can be created here: https://github.com/settings/tokens/new

When a token is generated, it should be placed at ~/.config/gitstrap/github_token.txt location.

CLI overview

The gitstrap CLI consists of these primary commands:

  • get - get GitHub resource, convert it into yaml format and print (possible sub-commands: repo, org, hooks, teams, protection)
  • create - create a new resource from spec yaml file, and fail if it already exists
  • apply - apply resource specification to existing resource or create it if doesn't exist
  • delete - delete resource by yaml spec

Global options:

  • --token - overrides GitHub token from ~/.config/gitstrap/github_token.txt

Use gitstrap --help or gitstrap <command> --help for more details.

Clone this wiki locally