This is a simple script that authenticates as a GitHub App, generates an installation token and runs a GitHub API request with this token built from the CLI arguments.
You can create a simple shell-script wrapper to run it:
#!/usr/bin/env sh
deno run --allow-read --allow-net https://gist.githubusercontent.com/laughedelic/1dbc334e2987286e6e1c536f2396523e/raw/dde6222a7bf7e368000a7029cb5dd011a279bb4b/github-app-request.ts --appId=123456 --installationId=12345678 --privateKey=private-key.pem $@
save it as github-app-request.sh
and make executable: chmod +x github-app-request.sh
, then you can call it like this:
./github-app-request.sh GET /repos/octokit/hello-world/deployments
You can pass any extra parameters as normal command line options:
./github-app-request.sh POST /repos/octokit/hello-world/deployments --ref='master'
Use jq
to extract information from the response and use it in the next request:
deployment_id=$(./github-app-request.sh POST /repos/octokit/hello-world/deployments --ref='master' | jq -r '.id')
./github-app-request.sh POST /repos/octokit/hello-world/deployments/$deployment_id/statuses \
--environment=staging \
--state=in_progress
This will create a deployment, save its ID to a var and then run a request to update this deployment status.
See https://deno.land/x/github_app_auth