I don't believe that political organisations are considered a protected class so yes, GitHub could decide to only host code for Democrats.
Your point seems to be "This is a slippery slope. Where do we draw the line?"
I think it is entirely reasonable that there _should_ be a line.
To take your example to the disturbing extreme, consider this: "Github refuses to work with ICE today and hypothetically tomorrow will refuse to build crematoria in extermination camps?"
There must be a line _somewhere_. Finding the best place to draw that line is a major challenge that requires significant and likely fraught discussion but it is something that must be done.