You can set up your repo to disable pushing directly to branches like main and require MFA to use the org admin account, so something malicious would need to push to a benign branch and separately be merged into one that deploys come from.
But the attacker could just create a branch, merge request and then merge that?
Pushing directly to main seems crazy - for anything that is remotely important I would use a pull request/merge request pattern