jhagestedt / ghapp

Lightweight CLI to create GitHub installation tokens for GitHub Apps.

Home Page:https://github.com/jhagestedt/ghapp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ghapp --help

Lightweight CLI to create GitHub installation tokens for GitHub Apps.

NAME:
   ghapp - GitHub App CLI

USAGE:
   ghapp [global options] command [command options] [arguments...]

COMMANDS:
   token, t  Create a GitHub App installation token
   help, h   Shows a list of commands or help for one command

πŸš€ Install

The packaged binaries of ghapp can be found on the releases of this repository.

🐧 Linux

curl -L "https://github.com/jhagestedt/ghapp/releases/latest/download/ghapp_linux_amd64" \
-o ./ghapp && chmod +x ./ghapp

🍏 MacOS

curl -L "https://github.com/jhagestedt/ghapp/releases/latest/download/ghapp_darwin_amd64" \
-o ./ghapp && chmod +x ./ghapp

πŸ§‘β€πŸ’» Usage

A GitHub App installation token can be created by the GitHub App id, the installation id and the private key like described in the docs.

To create an installation token with ghapp the private key can be injected via file or as environment variable.

The GitHub App id and installation id can be passed as flags or environment variables.

# load private key from file
ghapp token --id 123 --install-id 123456 --private-key-file .ghapp-private-key.pem

# load private key from environment variable
export GHAPP_PRIVATE_KEY=$(cat .ghapp-private-key.pem)
ghapp token --id 123 --install-id 123456

A usage on GitHub Actions could look like the following.

- id: setup-ghapp
  run: |
    curl -L "https://github.com/jhagestedt/ghapp/releases/latest/download/ghapp_linux_amd64" -o ./usr/local/bin/ghapp
    chmod +x ./usr/local/bin/ghapp
- id: ghapp-install-token
  run: |
    GHAPP_INSTALL_TOKEN=$(ghapp token)
    echo "::set-output name=ghapp_install_token::${GHAPP_INSTALL_TOKEN}"
  env:
    GHAPP_ID: 123
    GHAPP_INSTALL_ID: 123456
    GHAPP_PRIVATE_KEY: ${{ secrets.GHAPP_PRIVATE_KEY }}

🐳 Docker

There is also a docker container published at Dockerhub that contains the binary that can be used with docker run to not install it locally.

export GHAPP_PRIVATE_KEY=$(cat .ghapp-private-key.pem)
docker run --rm -e GHAPP_PRIVATE_KEY jhagestedt/ghapp token --id 123 --install-id 123456

About

Lightweight CLI to create GitHub installation tokens for GitHub Apps.

https://github.com/jhagestedt/ghapp

License:Apache License 2.0


Languages

Language:Go 85.4%Language:Shell 9.4%Language:Dockerfile 5.2%