Skip to content

stephenh1991/gha-token-generator

Repository files navigation

Github App Token Gen Utility

CircleCI

This app is a small binary which simplifies usage of Github App authentication (see this link for more info: link)

Installation

Download pre-compiled binaries (MacOS):

curl -L https://github.com/stephenh1991/gha-token-generator/releases/download/v1.0.1/gha-token-generator_1.0.1_Darwin_x86_64.tar.gz | tar xz

mv gha-token-generator /usr/local/bin/gha-token-generator

Download pre-compiled binaries (Linux):

curl -L https://github.com/stephenh1991/gha-token-generator/releases/download/v1.0.1/gha-token-generator_1.0.1_Linux_x86_64.tar.gz | tar xz

mv gha-token-generator /usr/local/bin/gha-token-generator

pre-built docker image: https://hub.docker.com/r/steveh1991/gha-token-generator

Quickstart

To run the tests locally run:

make generate-test-data

make test

To build locally, binaries are output in bin/:

make build

How it works

The pem key file generated via the Github console (see above docs for how this is done at the org level) is loaded via the -pem-key flag as a base64 encoded string.

Use the following flags to configure the generator:

  -app-id int
        Required: int value of installed Github App ID from the Github console
  -org-name string
        Required: name of the users github handle or organisation name where the Github app is installed
  -pem-key string
        Required: base64 encoded string form key.pem generated from Github App page

The base64 encoding is used to avoid line break stripping in the CI.

The token generator follows this flow:

All errors will exit the app and cause the current shell instance to fail with a useful error.

Releases

Releasing this app is done using go-releaser the config file resides in: .goreleaser.yml and more info can be found in the project itself: https://github.com/goreleaser/goreleaser