Carrier-envelope phase controlled dynamics of relativistic electron beams in a laser-wakefield accelerator