How to make your player invincible / undetectable by zombies?
Create a team:
1.13+: /team add friendly
1.12-: /scoreboard teams add friendly
Join the team:
1.13+: /team join friendly
1.12-: /scoreboard teams join friendly
On a clock, make all zombies join the team:
1.13+: /team join friendly @e[type=zombie]
1.10-: /scoreboard teams join friendly @e[type=Zombie]
Mobs in the same team as you will not attack you.