A very secure solution uses an optocouple. AsA 1kΩ resistor is good for an input voltage range of 5 to 20 volts. You may connect the two grounds, but it's not required.
The output is inverted, that means, the Pi senses low on it'sits GPIO if there is 5–12V5–20V on the input, and high if not.


simulate this circuitsimulate this circuit – Schematic created using CircuitLab