-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcomment.py
More file actions
executable file
·36 lines (26 loc) · 895 Bytes
/
comment.py
File metadata and controls
executable file
·36 lines (26 loc) · 895 Bytes
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
#!/usr/bin/env python2.7
import os
import sys
import requests
from fin.contextlog import Log
COMMENT_TEMPLATE = """Hi
Thanks for submitting this job advert.
%s
Thanks
Pythonjobs
"""
def add_comment(comment):
with Log("PR comment"):
if "TRAVIS_PULL_REQUEST" not in os.environ or os.environ["TRAVIS_PULL_REQUEST"] == 'false':
Log.output("No TRAVIS_PULL_REQUEST found, not commenting")
return
pr_num = os.environ["TRAVIS_PULL_REQUEST"]
url = "https://i2xwshcjfa.execute-api.eu-west-1.amazonaws.com/live/pythonjobs-commentbot/prcomment"
with Log("Submitting request"):
req = requests.post(
url, json={"pr": int(pr_num), "msg": COMMENT_TEMPLATE % comment},
)
print(req.text)
req.raise_for_status()
if __name__ == '__main__':
add_comment(sys.stdin.read().strip())