The sensor is made up of pixels, each of which is a MOS (metal-oxide semiconductor) capacitor. As the light falls on each pixel, the photons become electrons due to the photoelectric effect […] The photoelectric effect happens when photons of light hit the silicon of the pixel and knock electrons out of place. On a CCD, these electrons are stored in a "bucket": the pixel's capacitor.
At this stage, the "image" is still in analog form, with the charge, or amount of electrons in the bucket, on each pixel directly corresponding to the amount of light that has hit it. […]
[T]he charge in each row is moved from one site to the next, a step at a time. […] As these buckets of electrons reach the end of the line they are dumped out and measured, and this analog measurement is then turned into a digital value. Thus, a digital grid is made which describes the image.
Useless trivia: I actually am very familiar with this particular topic because while studying computer engineering in undergrad I wrote a research paper on this very thing for a holography course I was taking.