A would-be robber was caught allegedly performing a sex act on a mannequin during an attempted break-in at a Heidelberg Primary School, it has been reported.

Police say the 44-year-old Bright man was caught performing a lewd act on a mannequin crafted by students at St John's Primary School in Cape St, Heidelberg, the Leader newspaper reports.

The man is alleged to have broken into the school, but left empty-handed after being caught in the act.

Police say the man has been charged over the incident, which occurred at around 6am on Friday morning.