run water supply line to fridge from cold side of water heater
There is no issue with connecting to the cold supply line near the water heater.

However, there is a huge issue running plumbing through the attic. Attics are typically unconditioned spaces: they are not heated or cooled. In the winter, if you are in a cold climate, you have the possibility of freezing, and in summer, you will get very warm (or even hot) water from your fridge (the water that sits in the attic will heat up). 

Having the pipes insulated will slow things down, but if you don't use this water regularly you'll still have problems.

Best to keep all plumbing running through conditioned spaces (and interior walls).