automerge not working with Github
logs
2019/02/19 00:14:07+0000 [INFO] server: Parsed comment as command="apply" verbose=false dir="" workspace="" project="" flags=""
2019/02/19 00:14:07+0000 [INFO] server: POST /events – respond HTTP 200
2019/02/19 00:14:08+0000 [INFO] companyA/terraform-repo#1128: Pull request mergeable status: false
2019/02/19 00:14:09+0000 [INFO] server: POST /events – from 172.16.215.249:37950
2019/02/19 00:14:09+0000 [INFO] server: POST /events – respond HTTP 200
2019/02/19 00:14:10+0000 [INFO] companyA/terraform-repo#1128: Automerging pull request
2019/02/19 00:14:10+0000 [INFO] server: POST /events – from 172.16.212.244:44372
2019/02/19 00:14:10+0000 [INFO] server: POST /events – respond HTTP 200
2019/02/19 00:14:10+0000 [EROR] companyA/terraform-repo#1128: Automerging failed: merging pull request: PUT https://api.github.com/repos/companyA/terraform-repo/pulls/1128/merge: 405 You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information. []
- confirmed atlantis VCS user has
writepermission on above repo - atlantis args = [ "server", "--allow-repo-config", "--checkout-strategy=merge", "--automerge" ]
apply_requirements: [approved]- atlantis version
v0.4.15
PR status

Hi Camilo, In the end Atlantis is just making a "merge pull request" API call: https://github.com/runatlantis/atlantis/blob/master/server/events/vcs/github_client.go#L180 so I think the eventual solution to this issue will be about figuring out the correct permissions Atlantis needs to operate.
To investigate this, can you answer the following questions:
- Is your repo in an "organization" or under a personal repository
- Can you log in as the Atlantis user and screenshot the same PR status page you have above?
- Can you screenshot your permissions for the Atlantis user in respect to this repo (if you're using a personal repo) or in respect to this repo/organization (if you're using an organization)
Great points. I'll see about getting the password temporarily reset on the account, test and report back.
Thanks, Luke.
Okay great thank you. It will be good to document what we figure out so others don't have the same problems and maybe the Atlantis log message can be more helpful.
confirmed. the atlantis user isn't allowed to merge ...
So do you have this setting?

confirmed that the bot user was missing from that list.
added bot and saved
status changed ...

re-enabling auto-merge. i'm assuming this was root cause and auto-merge will work fine.
Thanks for helping out.
Root cause
bot user was listed as a collaborator with WRITE access however, the repository had master as a protected branch with only a specific team allowed to push to it.
resolution
added bot user to list of people/teams that can push to "matching branches" for protected branches
Resolved 👀☝️ . If you have the "Restrict who can push to this branch" setting then the Atlantis user must be in that list for it to automerge.