Positive work in the Carnot cycle
The Carnot cycle uses an idealized heat engine to illustrate basic thermodynamic principles. Net work is done either by or on the system, depending on the direction in which it is run. As part of this idealization, the piston is massless and frictionless. The piston merely serves as a moveable impermeable boundary between the system and the surroundings—i.e., as an interface that allows the system to do work on the surroundings, and visa versa. The piston exerts no force of its own, so no work is done by or on the piston; the piston merely serves as a conduit for force exerted by the system or surroundings, and is not part of either.
To more specifically address your question, since the piston is massless, its gravitational potential energy is zero, independent of position.
Also, as this is a cyclic process, the system is returned to its original state at the end of each cycle, and thus the piston is returned to its original height. [Hence, as Chet Miller points out in his comment, even if the piston had mass, its PE would be unchanged at the end of each cycle.]