I don’t see that you have a choice. This could play out in several ways. You confess and your friendship becomes a quick iceberg, or he is ok with you liking him but spends most of his time trying to convince you that he isn’t into you. Or he tells his girlfriend because his guilt compels him too and now you have an enemy in her and she convinces him to stop being your friend.
Or he does like you back and dumps his girlfriend. Well so much for loyalty. You will be a footnote in his life the moment someone else confesses their love for him and things have cooled between you two.
Or he figures he can have the both of you and that was his plan all along. After all, you have been sticking around like a loyal pet and he figures you will continue to hang around and won’t tell his girlfriend anything for fear of losing him.
Or as the saying goes. Nothing ventured nothing gained. Personally, it would probably be better not to say anything until their relationship dies in a normal teen fashion. Most high school relationship dies, unless someone ends up pregnant. Then it is either instant death or they wing it till the kid is about 6 and then they are bitter and resentful.
Probably just easier to let it go and stick to the books.