GitHub Action
Ubiquity Bounty Bot
This bot facilitates the Ubiquity Bounty System.
- This bot is designed to exist as a GitHub Action.
- The code must be compiled using
@vercel/ncc
because all the dependencies (e.g.node_modules
) must be included and committed on the repository for the GitHub Actions runner to use.
- Create a new project at Supabase
- Add Supabase's
Project URL
andAPI key
to repository secretsSUPABASE_PROJECT_URL
andSUPABASE_PROJECT_KEY
- Add a new github workflow which uses the action(use the latest commit hash):
name: Calculate Bounty Based on Issue Labels
on:
issues:
types:
- labeled
- unlabeled
jobs:
calculate_bounty_job:
# ignore events invoked by bots
if: >-
github.event.pull_request.payload.sender.type != 'Bot'
runs-on: ubuntu-latest
name: Calculate Bounty with UbiquiBot
steps:
- name: Ubiquity Bounty Bot
uses: ubiquity/bounty-bot@c1c6c99336f34ac5e94efaed49c9f218fb7a2d76
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPABASE_PROJECT_URL: ${{ secrets.SUPABASE_PROJECT_URL }}
SUPABASE_PROJECT_KEY: ${{ secrets.SUPABASE_PROJECT_KEY }}
yarn install
- Open 2 terminal instances:
- in one instance run
./node_modules/.bin/tsc --watch
(compiles the Typescript code) - in another instance run
yarn start:local:watch
(runs the bot locally)
- in one instance run
- Open
localhost:3000
and follow instructions to add the bot to one of your repositories. - Create a new project at Supabase. Add
Project URL
andAPI key
to the.env
file:
SUPABASE_PROJECT_URL=XXX
SUPABASE_PROJECT_KEY=XXX
At this point you can make changes to the repository on GitHub (e.g. add a bounty) and the bot should react. You can, for example:
- Create a new issue
- Add a time label, ex:
Time: <1 Day
- At this point the bot should add a price label, you should see event logs in one of your opened terminals
Bounty bot is built using the probot framework so initially the bot is a github app. But thanks to the probot/adapter-github-actions you can also use the bot as a github action.
You can use the bounty bot in 2 ways: github action or github app.
When using as a github action the flow is the following:
- Bounty bot is added to a repository as a github action
- Some event happens in a repository and the bot should react somehow (for example: on adding a time label to an issue the bot should add a price label)
- Github CI starts a runner (virtual linux machine)
- Event details are passed to the action directly in the runner
- The bot handles the event
Using the bounty bot as a github app is mostly useful for development. Github app is simply a server app that receives events from github via webhooks and can somehow react to those events. This way the bot should be deployed somewhere as it is a server app. When using the bot as a github app then the flow is the following:
- Bounty bot is added to a repository as a github app
- You run the bot "backend" (for example on your local machine)
- Some event happens in a repository and the bot should react somehow (for example: on adding a time label to an issue the bot should add a price label)
- Event details are sent to your deployed bot instance (to a webhook URL that was set in github app's settings)
- The bot handles the event
- Update the version in package.json:
yarn version --new-version x.x.x
- Commit and create a new tag:
git commit -am x.x.x && git tag -am x.x.x
- Push tags:
git push origin v"x.x.x"
- The Github action will create a release by recognizing the version tag