Imagine a trampoline stretched out, and place a bowling ball in the center of the trampoline. The weight of the bowling ball causes a depression or curvature in the trampoline. Now, if you roll a marble towards the bowling ball, the marble will follow the curved path created by the bowling ball's presence, even though the marble itself has no mass. In this analogy, the trampoline represents spacetime, the bowling ball represents a massive object, and the marble represents light.
Similarly, in the case of light, although it has no mass, it still follows the curvature of spacetime caused by massive objects. When light passes near a massive object, such as a star or a planet, the curvature of spacetime bends the path of light. This bending of light is known as gravitational lensing and is one of the key pieces of evidence supporting general relativity.
So, it is not the mass of light that determines its interaction with gravity, but rather the curvature of spacetime created by massive objects. Light, despite being massless, experiences the effects of gravity through the curvature of the fabric of spacetime.