fair-weather friend
A person who is dependable in good times but is not in times of trouble. For example, You can't rely on Sarahshe's strictly a fair-weather friend. This expression likens fair weather to good times. [Early 1700s]