[Google Pixel 2 XL Questions & Answers] annoyingduck:
Super easy. I'm assuming your bootloader is unlocked and your rooted or else you wouldn't be asking. Let's assume you are running the stock OS, you have TWRP recovery installed, you're rooted with Magisk, and maybe you also have a custom kernel installed. It's the first of the month and Google releases a new security patch. You cannot just take the OTA, nor can you just sideload the smaller OTA due to the custom recovery/root/other customizations. This is what you do, and this is what I do every month:

-Download the newly released FULL factory image from Google's site (NOT the smaller OTA package, the FULL image)

-Unzip the file, open it up, and inside there are multiple files and some zips. One file is a flash-all.bat (for Windows users) along with a flash-all.sh (for Linux/Mac users). Choose the file based on the OS you are using, open it up in a text editor and delete the -w part of the final command string. Be sure to save the file after doing this. This will eliminate the data wipe or essentially dirty flash the entire factory image without wiping your data.

-Reboot into Fastboot mode.

-Run the executable based on your OS. I use Linux, so I simply open a terminal within the files location and run the command "sudo ./flash-all.sh". For Windows you need to move the file to your platform tools folder then execute the flash-all.sh from within that folder as an administrator (double click it and authorize it). On Linux you need not move anything because Linux is ****ing awesome (assuming you have Android-Tools and Android-Udev installed).

-After you flash the entire image and the phone reboots, you simply reboot back into fastboot mode, fastboot boot TWRP, and re-root by flashing Magisk. Or you can fully install TWRP by fastboot booting TWRP, flashing TWRP, then flashing Magisk. If you're running a custom kernel do the same thing, but always flash Magisk last so it repacks the boot image properly.

-Boot back into the OS, and clear data on the Google Playstore. This will reset your Safetynet which was just set back to false after the new update and allow Magisk to continue to do it's thing and keep your device as being Safetynet certified.

-Done. It takes 10 min. and is very easy to do, but yes you do need to download the full 1.7gb FULL factory image. There are ways to do it with the smaller OTA file, but I'm not going to bother because it's useless and it's open to more problems, plus it takes longer and adds several more steps.

-If you are running a custom rom, the steps are a bit different, and in this case you can simply manually flash the desired partitions and eliminate the system image part of the flash. This still requires downloading the full factory image and manually updating the individual partitions that you want update (aka, bootloader, modem, tz, dtbo, etc). You do not run the flash-all script, rather you manually fastboot each partition you want updated. I run stock, so I'll leave these details out for someone else to chime in on. Essentially you are just going to manually flash the desired partitions to be current, but be prepared for breakage if the custom rom is not configured for the new partitions - like a new radio or bootloader.