Github Bot

2022-04-22

Github Bot

Register Heroku

Local setting

1
pip install gidgethub

get your Github Token

In Unix / Mac OS:

1
export GH_AUTH=your token

Local test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import asyncio
import os
import aiohttp
from gidgethub.aiohttp import GitHubAPI

async def main():

async with aiohttp.ClientSession() as session:
gh = GitHubAPI(session, "krnick", oauth_token=os.getenv("GH_AUTH"))

# 開啟新的 issue
await gh.post('/repos/krnick/Github-Bot/issues',
data={
'title': 'Hello Nick',
'body': 'This is github bot from JunWei',
})


# 關閉 issue
await gh.patch('/repos/krnick/Github-Bot/issues/1',
data={'state': 'closed'},
)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

deploy

create a new APP

auth

connect Github



Creat a new webhook at the repo you want to build



Set your key at Heroku

GH_AUTH

GH_SECRET

typo check repos example







Ref

https://github-bot-tutorial.readthedocs.io/en/latest/index.html