I was looking through the Sage Advice Compendium when I noticed this:
When you make a Strength (Athletics) check to grapple or shove someone, are you making an attack roll? Again, the answer is no. That check is an ability check, so game effects tied to attack rolls don’t apply to it. Going back to an earlier question, the hex spell could be used to diminish a grappler’s effectiveness. And if the grappler’s target is under the effect of the Dodge action, that action doesn’t inhibit the grapple, since Dodge doesn’t affect ability checks. I had always played that the 2nd Level Invisibility spell would end on a grapple, since it counts as an attack, but this seemed to suggest otherwise.
I researched this a bit and found a post by Jeremy Crawford in Sage Advice, which seemed to suggest that it was indeed an attack roll.
Grappling/shoving an enemy does end the sanctuary spell on you, since you have made an attack.
My best guess is that you must take the attack action to perform an ability check, as grappling in the PHB is called a “special Melee attack”, although that doesn't make a huge amount of sense.
...you can use the Attack action to make a special melee attack, a grapple.... ( PHB p.195:)
Do these two Sage Advice answers contradict each other? And should invisibility end when a grapple is attempted?
The description for invisibility is shown below.
A creature you touch becomes Invisible until the spell ends. Anything the target is wearing or carrying is Invisible as long as it is on the target's person. The spell ends for a target that attacks or casts a spell.