All of the webhooks the website uses for updates
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1009 B

  1. import sys
  2. import os
  3. import requests
  4. import json
  5. import os
  6. from datetime import datetime
  7. TOKEN = os.environ["GITEA_API_KEY"]
  8. def grab(url):
  9. r = requests.get(url, headers = {
  10. "authorization": "token " + TOKEN
  11. })
  12. if r.status_code != 200:
  13. print(url)
  14. print("oops...")
  15. print(r.text)
  16. sys.exit(1)
  17. return json.loads(r.text)
  18. url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/releases".format(sys.argv[1])
  19. tag = grab(url)[0]["tag_name"]
  20. url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/commits?sha={1}".format(sys.argv[1], tag)
  21. data = grab(url)[1:]
  22. results = []
  23. for commit in data:
  24. result = {}
  25. lines = commit["commit"]["message"].split("\n")
  26. subject = lines[0]
  27. body = "\n".join(lines[2:])
  28. result["date"] = datetime.fromisoformat(commit["commit"]["author"]["date"]).strftime("%B %d")
  29. result["subject"] = subject
  30. result["body"] = body
  31. results.append(result)
  32. with open(sys.argv[2], "w", encoding="utf-8") as file:
  33. json.dump(results[::-1], file)