Ants hate strong smells. They rely on scent trails to find the coffee grounds you spilled. You can literally break their GPS system with stuff from your kitchen. Try sprinkling cinnamon (powder or sticks), mint leaves, or coffee grounds around the perimeter of your garden beds.
Another weird trick? Cucumber peels. Ants supposedly hate the bitterness. I once lined my entire raised bed with lemon rinds and old mint tea bags. Did it look like a compost bin threw up? Yes. Did the ants get confused and move out? Also yes. Looks don't count when you're winning a war.
7 ways to get rid of an ants nest - 'Go straight for the source