Command line tool to bootstrap Github repository
Clone or download
Latest commit 3d5ef45 Jan 14, 2019

README.md

Gitstrap

Command line tool to bootstrap Github repository.

Donate via Zerocracy DevOps By Rultor.com Managed by Zerocracy

Build Status

PDD status License

About

This tool automates routine operations when creating new Github repository. It can create and configure Github repository from yaml configuration file. Gitstrap helps to:

  1. Create new repository on Github
  2. Sync with local directory
  3. Apply templates (such as README with badges, CI configs, LICENSE stuff, etc)
  4. Configure webhooks for Github repo
  5. Invite collaborators

Install

Download binary

You can download a binary for your platform using download script:

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

or you can download it manually from releases page.

Gentoo

Use my repo Layman overlay:

sudo layman -o https://raw.githubusercontent.com/g4s8-overlay/layman/master/repositories.xml -a g4s8
sudo emerge -av dev-vcs/gitstrap

Homebrew

On macOS you can install it using brew tool:

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

Get sources

If you have go installed, you can use go get github.com/g4s8/gitstrap to download gitstrap tool and build a binary.

Alternatively you can clone it from Github:

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

Usage

Before using, make sure you have running ssh-agent daemon with imported your github ssh key to be able to push, fetch and pull.

To bootstrap new repository:

  1. Create new directory for your project
  2. Write .gitstrap.yaml config in project root
  3. Create Github API token with repo permissions (if doesn't exist)
  4. Run gitstrap -token=your-api-token create

To remove repository (keep source files) run gitstrap -token=your-api-token destroy

To create or destroy a repo for an organization make sure you have permissions to create or delete repositories and use -org=orgname gitstrap option.

Configuration

The default configuration file is .gitstrap.yaml, you can specify another file with -config=my-config.yaml option.

Each config should include gitstrap key with version v1. gitstrap section must include github section and may include templates and params sections:

gitstrap:
    version: v1
    github:
        repo:
            # github repository name
            name: gitstrap
            # github repository description
            description: "Command line tool to bootstrap Github repository"
            # (optional, default false) true if private
            private: false
            # github webhooks
            hooks:
                  # webhook url
                - url: "http://p.rehttp.net/http://www.0pdd.com/hook/github"
                  # webhook type: form or json
                  type: form
                  # events to send (see github docs)
                  events:
                      - push
                  # (optional, default true) false to create webhook in inactive state
                  active: true
            # github logins to add as collaborators
            collaborators:
                - "rultor"
                - "0pdd"
    # (optional) templates to apply
    templates:
          # file name in repository
        - name: "README.md"
          # template url
          url: "https://raw.githubusercontent.com/g4s8/gitstrap/master/templates/README.md"
        - name: "LICENSE"
          location: "/home/g4s8/.gitstrap/LICENSE.mit"
    # (optional) these params can be accessed from template, just a key-value pairs
    params:
        rultor: true
        travis: true
        readmeContrib: |
            Fork repository, clone it, make changes,
            push to new branch and submit a pull request.
        pdd: true
        license: MIT

Templates

You can create any file templates to apply them using project configuration. Templates can use golang template patterns.

Example: README.md

# {{.Repo.Name}}.
{{.Repo.Description}}

{{if .Gitstrap.Params.eoPrinciples }}[![EO principles respected here](http://www.elegantobjects.org/badge.svg)](http://www.elegantobjects.org){{end}}
{{if .Gitstrap.Params.rultor}}[![DevOps By Rultor.com](http://www.rultor.com/b/{{.Repo.Owner.Login}}/{{.Repo.Name}})](http://www.rultor.com/p/{{.Repo.Owner.Login}}/{{.Repo.Name}}){{end}}

{{if .Gitstrap.Params.travis}}[![Build Status](https://img.shields.io/travis/{{.Repo.Owner.Login}}/{{.Repo.Name}}.svg?style=flat-square)](https://travis-ci.org/{{.Repo.Owner.Login}}/{{.Repo.Name}}){{end}}
{{if .Gitstrap.Params.appveyor}}[![Build status](https://ci.appveyor.com/api/projects/status/{{.Gitstrap.Params.appveyor}}?svg=true)](https://ci.appveyor.com/project/{{.Repo.Owner.Login}}/{{.Repo.Name}}){{end}}
{{if .Gitstrap.Params.pdd}}[![PDD status](http://www.0pdd.com/svg?name={{.Repo.Owner.Login}}/{{.Repo.Name}})](http://www.0pdd.com/p?name={{.Repo.Owner.Login}}/{{.Repo.Name}}){{end}}
{{if .Gitstrap.Params.license}}[![License](https://img.shields.io/github/license/{{.Repo.Owner.Login}}/{{.Repo.Name}}.svg?style=flat-square)](https://github.com/{{.Repo.Owner.Login}}/{{.Repo.Name}}/blob/master/LICENSE){{end}}
{{if .Gitstrap.Params.codecov}}[![Test Coverage](https://img.shields.io/codecov/c/github/{{.Repo.Owner.Login}}/{{.Repo.Name}}.svg?style=flat-square)](https://codecov.io/github/{{.Repo.Owner.Login}}/{{.Repo.Name}}?branch=master){{end}}

this template uses .gitstrap.yaml config and produces README.md:

# gitstrap.
Command line tool to bootstrap Github repository

[![DevOps By Rultor.com](http://www.rultor.com/b/g4s8/gitstrap)](http://www.rultor.com/p/g4s8/gitstrap)

[![Build Status](https://img.shields.io/travis/g4s8/gitstrap.svg?style=flat-square)](https://travis-ci.org/g4s8/gitstrap)

[![PDD status](http://www.0pdd.com/svg?name=g4s8/gitstrap)](http://www.0pdd.com/p?name=g4s8/gitstrap)
[![License](https://img.shields.io/github/license/g4s8/gitstrap.svg?style=flat-square)](https://github.com/g4s8/gitstrap/blob/master/LICENSE)