If you wanted your original concept, with just green and yellow, you could try working in black and white, then colorize it with an adjustment layer. How successful this method will be will depend largely on how much contrast you can create in you background. If you can make it truly black and white vs shades of gray, then it should be pretty successful.
So step one would be to make your background B&W, if you can simple make the green parts black and the yellow white, then you’re ready to go. If it’s not quite that simple, then I’d try Threshold and adjust it until you separate those colors into black or white. Possibly using the tint effect (to make the background gray scale) and then levels, curves or other effect to adjust contrast as needed may work.
Once you have a B&W background, you can simply do what Graham mentioned, but use white text and set the blending mode to Difference. This should make any text over white black and any text over black white. If there are shades of gray the text will also become a shade of gray, so that’s why contrast is important in the background.
The you can colorize everything back to yellow and green with an adjustment layer and adding the tint effect. Click the white chip and set it to yellow and set the other chip to green.