Preheat oven to 200°C.
Cut a 2cm strip from one long side of the pastry (for the stems). Spread pesto and cheese on the remaining rectangle, then roll both long sides toward the middle until they meet.
Cut the log into 1cm-thick slices and pinch the bottom of each slice to form a heart shape. Arrange three hearts together on a lined baking tray to create a shamrock shape. Cut the reserved strip of dough into stems and roll into tubes; lightly press onto the shamrocks.
Whisk egg and brush over shamrocks. Bake for about 20 minutes, until puffed and golden.