fair-weather friend
One who is friendly, helpful, or available only when it is advantageous or convenient to be so.
My Fair-weather Friends of the Summer are going away for London, and I ſhall ſee them and the butterflies together, if I live till next Year; which I would not deſire to do, if it