in webhooks-with-cloud-run/MicroServices/GitHub/github.py [0:0]
def create_issue_comment(api_url):
# Posts an auto response to Github Issue
# Get tokens
pem = get_secret(os.environ.get("PROJECT_NAME"), os.environ.get("PEM"), "1")
app_token = get_jwt(pem)
installation_token = get_installation_token(app_token)
# Create Github issue comment via HTTP POST
try:
msg = {
"body": "Thank you for filing an issue. \
Someone will respond within 24 hours."
}
req = urllib.request.Request(
api_url + "/comments", data=json.dumps(msg).encode("utf8")
)
req.add_header("Authorization", f"Bearer {installation_token}")
response = urllib.request.urlopen(req)
except Exception as e:
print(e)