2
0

automerge.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. function _get_autoupdate_pr_list()
  2. local result = {}
  3. local list = os.iorun("gh pr list --label auto-update --state open -R xmake-io/xmake-repo")
  4. if list then
  5. for _, line in ipairs(list:split("\n")) do
  6. if line:find("Auto-update", 1, true) then
  7. local id = line:match("(%d+)%s+Auto%-update")
  8. if id then
  9. table.insert(result, {id = id, title = line})
  10. end
  11. end
  12. end
  13. end
  14. return result
  15. end
  16. function _check_pr_passed(id)
  17. local ok = os.vexecv("gh", {"pr", "checks", id, "-R", "xmake-io/xmake-repo"}, {try = true})
  18. if ok == 0 then
  19. return true
  20. end
  21. end
  22. function main()
  23. local pr_list = _get_autoupdate_pr_list()
  24. for _, info in ipairs(pr_list) do
  25. local id = info.id
  26. local title = info.title
  27. print("checking %s ...", title)
  28. if _check_pr_passed(id) then
  29. print("pull/%d passed, it will be merged next.", id)
  30. os.vexec("gh pr merge %d --squash -d -R xmake-io/xmake-repo", id)
  31. end
  32. end
  33. end