Work is underway on a new £6.4m scheme that will help to defend Porthcawl from flooding and any potential future rise in sea levels.