Deploy key with write access fails on push rules

Summary

Prior to Gitlab 12.0, a deploy key with write access was not affected by push rules "Committer restriction" and "Check whether author is a Gitlab user". Currently it is impossible to push a commit via deploy key with either of these rules active.

Steps to reproduce

  1. Create a new empty project
  2. Create a deploy key with write access
  3. Commit and push a CI setup that pushes a commit in it's pipeline (see example project)
  4. Start a new pipeline (it should pass)
  5. Enable either combination of "Committer restriction" and "Check whether author is a Gitlab user"
  6. Start a new pipeline (it should fail)

Example Project

https://gitlab.com/csvn/deploy-key-push-rule-issues-reproduction

What is the current bug behavior?

Push fails with "remote: GitLab: You cannot push commits for 'xxx@yyy.zzz'. You can only push commits that were committed with one of your own verified emails." or "remote: GitLab: Author 'xxx@yyy.zzz' is not a member of team"

What is the expected correct behavior?

Push should succeed without errors

Relevant logs and/or screenshots

https://gitlab.com/csvn/deploy-key-push-rule-issues-reproduction/-/jobs/270723700
https://gitlab.com/csvn/deploy-key-push-rule-issues-reproduction/-/jobs/270731960

Output of checks

This bug happens on GitLab.com (12.2.0-pre 0874a8d346c)

Results of GitLab environment info

Results of GitLab application Check

Possible fixes