I've taken public transportation several times with my bicycle from Portland out to the Oregon Coast.
From what I remember, the Amtrak Thruway bus that departs from Portland Union Station to Cannon Beach, Seaside, and Astoria will take unboxed bicycles. There's an extra surcharge ($5 from what I remember) for the bike. The main catch with this bus is it has one daily departure from Portland at 6pm, so it doesn't get to the coast until about 8pm. The closest state park camping by Astoria is Fort Stevens, which is about a 10 mile ride, so if that's where you plan on staying for the night bring lights and be ready to ride in the dark.
I've used the
Tillamook bus ("The Wave") several times. They have a rack on the front for two bikes, but if the bus isn't completely full (and someone isn't needing the wheelchair area) the drivers will usually let you bring bikes on the bus. Or you can reserve your seat and a bike spot in advance if you're worried about there being no room. The Tillamook bus leaves Portland Union Station twice daily Mon-Sat at 10:15am and 3pm, so there's more time for riding after you get to Tillamook. (They have a daily option on Sunday around 6pm.) And the best part is the price: $10 one-way ($15 round trip), no bike surcharge.
Of course the biggest issue is that the Wave bus ends in Tillamook, a full 50 miles south of Astoria. If you want to and feel particularly adventurous, you CAN take other local public transit buses north up US 101 all the way to Astoria (and beyond to Aberdeen, Washington if you're REALLY feeling adventurous), but there will be plenty of transfers and it will probably end up taking all day. You can ride about 25 miles north (or take a bus) on US 101 to
Nehalem Bay State Park, which has hiker/biker sites, or ride about 10 miles west of Tillamook to
Cape Lookout State Park, which is my favorite hiker/biker campground on the Oregon Coast!