Buckling-controlled two-way shape memory effect in a ring-shaped bilayer