-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstatus.py
69 lines (61 loc) · 2.02 KB
/
status.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from buildbot.plugins import util
@util.renderer
def get_github_app_token(props):
# https://github.com/vaspapadopoulos/github-app-auth
import datetime
import requests
import jwt
import private
with open(private.github_app_private_key_file, "r") as key_file:
key = key_file.read()
now = int(datetime.datetime.now().timestamp())
payload = {
"iat": now - 60,
"exp": now + 60 * 8, # expire after 8 minutes
"iss": private.github_app_id,
"alg": "RS256"
}
encoded = jwt.encode(payload=payload, key=key, algorithm="RS256")
response = requests.post(f"https://api.github.com/app/installations/{private.github_app_installation_id}/access_tokens", headers={"Authorization": f"Bearer {encoded}"})
return response.json()["token"]
def get_www():
from buildbot.plugins import util
from twisted.cred import strcred
import private
return dict(
port = "unix:/home/buildbot/buildbot.sock",
plugins = dict(
waterfall_view = True,
console_view = True,
grid_view = True,
badges = {}
),
auth = util.GitHubAuth(
private.github_client_id,
private.github_client_secret,
apiVersion = 4,
getTeamsMembership = True
),
authz = util.Authz(
allowRules = [
util.AnyControlEndpointMatcher(role = "SFML")
],
roleMatchers = [
util.RolesFromGroups()
]
),
change_hook_dialects = {'base': True, 'github' : {}},
change_hook_auth = [strcred.makeChecker("file:changehook.passwd")],
ws_ping_interval = 15
)
def get_github_status():
from buildbot.process.properties import Interpolate
from buildbot.plugins import reporters
import private
return [
reporters.GitHubStatusPush(
token = get_github_app_token,
context = Interpolate("%(prop:buildername)s"),
verbose = True
)
]