GitHub Integration
Squawk works as a CLI tool but can also create comments on GitHub Pull
Requests using the upload-to-github
subcommand.
Here's a screenshot of an example comment created by squawk
using the example.sql
in the repo:
https://github.com/sbdchd/squawk/pull/14#issuecomment-647009446
This document provides instructions for using the Squawk GitHub Action and using Squawk as GitHub App.
If you're using GitHub Actions, we recommend using the squawk-action. If you're using Squawk outside of GitHub Actions, like on CircleCI for example, you should configure Squawk as a GitHub App.
#
Squawk GitHub ActionThis easiest way to integrate Squawk with GitHub is the Squawk GitHub Action.
For more information, see the Squawk GitHub Action documentation.
#
Custom GitHub ActionIf you want to make your own GitHub Action, you can call Squawk using the following code:
#
Squawk as a GitHub AppIf you use Squawk outside of a GitHub Actions, we recommend configuring Squawk as a GitHub App.
To use Squawk as a GitHub App, Squawk needs a corresponding GitHub App so it can talk to GitHub.
Create the app
head over to https://github.com/settings/apps/new
add an app name & homepage url
Uncheck the
active
checkbox under Webhookadd permissions
name kind why Pull Requests Write to comment on PRs hit create and copy the
App ID
under the "About" section. The page URL should be: https://github.com/settings/apps/$YOUR_APP_NAME
Head down the the bottom of the page under the "Private Keys" section and hit "Generate a private key"
The key should automatically download after a couple seconds. Hold onto this key, we'll need it later.
We now have an
App ID
and aPrivate Key
, which is everything we neeed to install the GitHub App.Install the GitHub App & get the Install ID
Head to https://github.com/settings/apps/$YOUR_APP_NAME/installations and click "Install"
GitHub should have redirected you to the https://github.com/settings/installations/$INSTALL_ID page where
$INSTALL_ID
is some number.Save this ID for later.
Now we have our
SQUAWK_GITHUB_APP_ID
,SQUAWK_GITHUB_PRIVATE_KEY
,SQUAWK_GITHUB_INSTALL_ID
.Squawk needs the pull request related values:
SQUAWK_GITHUB_REPO_NAME
,SQUAWK_GITHUB_REPO_OWNER
, andSQUAWK_GITHUB_PR_NUMBER
.Where to find these varies depending how you're running squawk, but for the next step I'm assuming you're running Squawk as a CircleCI job.
Finding the Pull Request variables
#
CircleCIhttps://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
CIRCLE_PULL_REQUEST
has the content we needexample:
https://github.com/recipeyak/recipeyak/pull/567
Now we need to split this to get the repo name, repo owner, and pull requeset id.
With a bit of help from
Conclusion
Wrapping it all up we should have the following env vars:
We can pass this into the env before running squawk or we can translate them to the command line flag. Whatever's easiest for you.
An example run will look like the following (assuming the env vars are set):
which creates a comment like the following:
https://github.com/sbdchd/squawk/pull/14#issuecomment-647009446