7
7
# URLs of old highfive instances
8
8
# Webhooks with this URL will be edited to point to the new instance
9
9
REPLACE_OLD_URLS = [
10
- "https://www.ncameron.org/highfive/newpr.py"
10
+ "https://www.ncameron.org/highfive/newpr.py" ,
11
+ "https://internal-secret-rust-bots.rust-lang.org/highfive/newpr.py" ,
11
12
]
12
13
13
14
# URL of the current instance
14
- CURRENT_URL = "https://internal-secret-rust-bots. rust-lang.org/highfive/newpr.py "
15
+ CURRENT_URL = "https://highfive.infra. rust-lang.org/webhook "
15
16
16
17
# Events the current instance requires
17
18
EVENTS = [
@@ -51,7 +52,7 @@ def find_config_files(path):
51
52
result .append (file )
52
53
return result
53
54
54
- def update_webhook (config , api ):
55
+ def update_webhook (config , api , secret ):
55
56
"""Update the webhook of a single file"""
56
57
name = os .path .basename (config ).rsplit ("." , 1 )[0 ]
57
58
org = os .path .basename (os .path .dirname (config ))
@@ -82,6 +83,7 @@ def update_webhook(config, api):
82
83
api .req ("POST" , "repos/%s/%s/hooks" , org , name , data = {
83
84
"config" : {
84
85
"url" : CURRENT_URL ,
86
+ "secret" : secret ,
85
87
"content_type" : "form" ,
86
88
"insecure_ssl" : 0 ,
87
89
},
@@ -93,6 +95,7 @@ def update_webhook(config, api):
93
95
api .req ("PATCH" , "repos/%s/%s/hooks/%s" , org , name , replace , data = {
94
96
"config" : {
95
97
"url" : CURRENT_URL ,
98
+ "secret" : secret ,
96
99
"content_type" : "form" ,
97
100
"insecure_ssl" : 0 ,
98
101
},
@@ -107,5 +110,7 @@ def update_webhook(config, api):
107
110
exit (1 )
108
111
api = GitHubApi (os .environ ["GITHUB_TOKEN" ])
109
112
113
+ secret = input ("Please enter the webhooks' secret key: " )
114
+
110
115
for config in find_config_files ("highfive/configs" ):
111
- update_webhook (config , api )
116
+ update_webhook (config , api , secret )
0 commit comments