Upgrade Operating system of CAS and Primary Sites

Hello, what is the best way to upgrade my OS. I have installing a Windows Server 2012 with CAS and another server with primary. I want upgrade to Windows Server 2019, but i dont know how can i do with sccm. My SCCM version is 2006.