Skip to content

buildooor/github-attestation-bot

Repository files navigation

GitHub PR Attestation Bot

A GitHub PR Attestation Bot that automatically make an attestation to the Ethereum Attestation Service every time a PR is merged into a repository's main branch. This attestation contains a reference to the repository, the specific PR number, the branch name the PR was merged to, and the GitHub username of the account that created the PR.

Example pull request merged with attestation bot submission:

buildooor/github-action-test#31

Demo Bot Install

https://github.com/apps/pr-attestation

Install the demo bot on your repository to see how it works. The bot will automatically make an attestation to the Ethereum Attestation Service on Sepolia every time a PR is merged into the master branch of the selected repository.

Install your own bot

Development

Install dependencies:

npm install

Build:

npm run build

Set up environmtent variables:

cp sample.env .env

Environment variables:

# Signer private key (required)
PRIVATE_KEY=

# Github personal token of bot account (required)
GITHUB_TOKEN=

# Github webook secret (optional)
GITHUB_WEBHOOK_SECRET=

# Network to post attestation to (default "sepolia")
NETWORK=sepolia

# RPC URL to use (optional)
RPC_URL=

# The main branch to trigger attestations on when PR is merged (default "main")
BRANCH=main

Run:

npm run start

The webhook will be available at http:https://localhost:8000/payload.

Docker

Alternatively, you can run the bot in a Docker container.

Build:

docker build -t github-attestation-bot .

Run:

docker run --env-file=.env -p 8000:8000 github-attestation-bot

Github App Setup

You will need to create a Github App to use trigger the bot server via webhooks.

  1. Go to [https://github.com/settings/apps]
  2. Click "New Github App" button
  3. Fill out "GitHub App name" and "Homepage URL" fields
  4. Fill out "Webhook URL", add the URL of the bot server: http:https://<bot-server-ip>:8000/payload. If you are running the bot locally, you can use ngrok to create a tunnel to your local server.
  5. Under "Repository permissions" and "Pull requests", select "Read and write" access
  6. Under "Subscribe to events", check "Pull request"
  7. Click "Create GitHub App"
  8. After creation, click on "Generate a private key"
  9. Click on "Permissions & events" on the sidebar

References

License

MIT