/substrate-tip-bot

A GitHub bot to submit tips on behalf of contributors

Primary LanguageTypeScriptMIT LicenseMIT

substrate-tip-bot

A GitHub App built with Probot that can submit tips on behalf of a Substrate based network.

Getting started 🌱

Usage

This bot relies on GitHub pull request that opt in via a body text comment to specify what Substrate network and address to send tips to.

Pull request body

{kusama|polkadot|localtest} address: <SS58 Address>

Followed by a comment on said pull request

Pull request comment

/tip {small | medium | large}

Local development 🔧

To use this bot, you'll need to have an .env file. Most of the options will automatically be generated by the GitHub application creation process, but you will also need to add ACCOUNT_SEED and ALLOWED_USERS.

A reference env file is placed at .env.example to copy over

$ cp .env.example .env

Run polkadot or substrate localtest network locally

Create GitHub application for testing

Github app permissions

Repository permissions:
  • Issues: Read-only
    • Allows for interacting with the comments API
  • Pull Requests: Read & write
    • Allows for posting comments on pull requests
Organization permissions
  • Members: Read-only
    • Related to $ALLOWED_ORGANIZATIONS: this permission enables the bot to request the organization membership of the command's requester even if their membership is private
Event subscriptions
  • Issue comment
    • Allows for receiving events for pull request comments

Start a bot

After registering and configuring the bot environment, we can run it. We use Nodemon for hot-reloading, the probot package automatically parses the relevant .env values.

$ yarn start

Create a PR and test it

You'll need 2 gh users: contributor and maintainer (since it's not allowed for contributors to send a tip to themselves)

  • From contributor GH account: create a PR and add into PR description localtest address: <contributor polkadot address>
  • From maintainer GH account: write /tip small in comments so the bot sends funds to

Docker

To run the bot via Docker, we need to build and then run it like so

$ docker build -t substrate-tip-bot .
$ docker run \
    -e APP_ID=<app-id> \
    -e PRIVATE_KEY=<pem-value> \
    substrate-tip-bot

Contributing

If you have suggestions for how substrate-tip-bot could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

License

MIT © 2021 Parity Technologies admin@parity.io