Coder.comC
Coder.com13mo ago
6 replies
arkevorkhat

github private repo won't pull

I'll be fully honest here, I think this is an issue with the documentation.

I'm using the external auth method that has been recommended here a couple times.

I've gotten as far as installing the github app for my organization, and now I have a bunch of environment variables, but it's not specified what environment they need to be set in.
Are these supposed to be set in the terraform code for my template? In the docker compose file that defines my coder install? somewhere else?
Solution
OK, turns out this was a layer-8 issue, though a very subtle/frustrating one.

Turns out docker compose -f coder.yml restart doesn't actually refresh the environment variables, so none of the changes I was making were getting shown to coder. This resolved itself after I used docker compose ... down followed by docker compose ... up -d.

Edit to add:
The final solution was the following:
Coder.yml (Docker compose)
services:
  coder:
    environment:
        ...
       CODER_EXTERNAL_AUTH_0_ID: "github-auth"
       CODER_EXTERNAL_AUTH_0_TYPE: "github"
       CODER_EXTERNAL_AUTH_0_CLIENT_ID: <nope>
       CODER_EXTERNAL_AUTH_0_CLIENT_SECRET: <lolno>
        ...

main.tf (terraform source code for template)
...
data "coder_workspace_owner" "me" {}
data "coder_external_auth" "github" {
  id = "github-auth" # or whatever you set CODER_EXTERNAL_AUTH_0_ID to be
}
...
locals {
  envbuilder_env = {
    ...
    "ENVBUILDER_GIT_USERNAME": data.coder_external_auth.github.access_token
  }
...
}


Once you've made those additions, built, and published your template, you can then start to create a workspace, authenticate with github, and finally provide the https link to your private repository.

Some pitfalls to watch out for:
* If you're getting a 404 error, check the following:
* that the callback url in the github url matches the one you put into your app
* that the client id matches your github app
Was this page helpful?