Usually the protection against such spam is social shame but the internet is now full of people who have no shame because shame was never part of their culture. It would be more effective to use GeoIP in this case.
I wonder how much of it could be stopped just by charging $5 a month to contribute to public open source repos. Even if github gave the $5 back in LLM credits or something it would at least put up a barrier. The reason there is so much traffic from third world countries is because the cost of accessing the internet is effectively zero.