How do I cause a shovel with Mending to heal itself?

According to the Minecraft Enchanting wikia page:

When an item with the enchantment is held (main hand, offhand, or armor slots), XP orbs collected will repair the item at a rate of 2 durability per XP instead of adding the XP to the player's total. If multiple items have the enchantment, one will be chosen at random for each XP orb collected, and if the chosen item does not need repair, the XP will be added to the player's total as normal, rather than choosing another item to repair.

Thus, it looks like just having your Mending Shovel equipped while gaining EXP orbs will allow it to repair itself.