77# URLs of old highfive instances
88# Webhooks with this URL will be edited to point to the new instance
99REPLACE_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" ,
1112]
1213
1314# 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 "
1516
1617# Events the current instance requires
1718EVENTS = [
@@ -51,7 +52,7 @@ def find_config_files(path):
5152 result .append (file )
5253 return result
5354
54- def update_webhook (config , api ):
55+ def update_webhook (config , api , secret ):
5556 """Update the webhook of a single file"""
5657 name = os .path .basename (config ).rsplit ("." , 1 )[0 ]
5758 org = os .path .basename (os .path .dirname (config ))
@@ -82,6 +83,7 @@ def update_webhook(config, api):
8283 api .req ("POST" , "repos/%s/%s/hooks" , org , name , data = {
8384 "config" : {
8485 "url" : CURRENT_URL ,
86+ "secret" : secret ,
8587 "content_type" : "form" ,
8688 "insecure_ssl" : 0 ,
8789 },
@@ -93,6 +95,7 @@ def update_webhook(config, api):
9395 api .req ("PATCH" , "repos/%s/%s/hooks/%s" , org , name , replace , data = {
9496 "config" : {
9597 "url" : CURRENT_URL ,
98+ "secret" : secret ,
9699 "content_type" : "form" ,
97100 "insecure_ssl" : 0 ,
98101 },
@@ -107,5 +110,7 @@ def update_webhook(config, api):
107110 exit (1 )
108111 api = GitHubApi (os .environ ["GITHUB_TOKEN" ])
109112
113+ secret = input ("Please enter the webhooks' secret key: " )
114+
110115 for config in find_config_files ("highfive/configs" ):
111- update_webhook (config , api )
116+ update_webhook (config , api , secret )
0 commit comments