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.
 
 
 

49 lines
1.0 KiB

  1. import sys
  2. import os
  3. import requests
  4. import json
  5. import os
  6. import subprocess
  7. from datetime import datetime
  8. TOKEN = os.environ["GITEA_API_KEY"]
  9. def grab(url):
  10. r = requests.get(url, headers = {
  11. "authorization": "token " + TOKEN
  12. })
  13. if r.status_code != 200:
  14. print(url)
  15. print("oops...")
  16. print(r.text)
  17. sys.exit(1)
  18. return json.loads(r.text)
  19. url = "https://git.crux.best/api/v1/repos/chemicalcrux/{0}/releases".format(sys.argv[1])
  20. data = grab(url)
  21. if data:
  22. spec = data[0]["tag_name"] + "..master"
  23. else:
  24. spec = "master"
  25. output = subprocess.check_output(["git", "log", r"--pretty=format:%aI%x00%s%x00%b%x00", spec]).decode("utf-8").split("\x00")
  26. data = []
  27. # last item is an empty string
  28. for i in range(0, len(output)-1, 3):
  29. entry = {}
  30. entry["date"] = output[i].strip()
  31. entry["date"] = datetime.fromisoformat(entry["date"]).strftime("%B %d")
  32. entry["subject"] = output[i+1].strip()
  33. entry["body"] = output[i+2].strip()
  34. data.append(entry)
  35. with open(sys.argv[2], "w", encoding="utf-8") as file:
  36. json.dump(data, file)