Skip to content

feat: add support for custom github url #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

renebarak
Copy link

This change is adding support for custom GitHub URL value (e.g., to support Enterprise GitHub URLs). It is backwards compatible with the previous version and uses the same default as before.

matifali
matifali previously approved these changes Jun 25, 2025
Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@matifali matifali dismissed their stale review June 25, 2025 16:27

Looks like it's not enough.

@Jphalan
Copy link

Jphalan commented Jun 25, 2025

@matifali a little more context:
-Customer discovered this github action: (https://github.com/coder/start-workspace-action/tree/main).
-It doesn't support github enterprise override, it always invokes github.com (code reference: https://github.com/coder/start-workspace-action/blob/main/action.yml#L47)
-Goal: Expose that as an additional parameter?"

@hugodutka
Copy link
Collaborator

@renebarak thanks for the PR! There were a couple of other changes required to support a custom GitHub URL and I made a new PR with them: #4. I don't have access to a GitHub enterprise instance - would you be able to check if the new version of the action works for you? You can use it in a workflow like so:

# ...
    steps:
      - name: Start Coder workspace
        uses: coder/start-workspace-action@2ef956daeea4f43565d6db29972e20adf9f653b6
# ...        

@renebarak
Copy link
Author

@hugodutka thank you for making this change. Unfortunately, it didn't work for me. I'm running into an issue detecting a username:

Getting Coder username for GitHub user rbarak
GET /users/rbarak - 406 with id xxxxxxxx in 137ms
RequestError [HttpError]
    at fetchWrapper (file:///runner/_work/_actions/coder/start-workspace-action/xxxxxxxx/dist/index.js:23461:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async StartWorkspaceAction.githubGetUserIdFromUsername (file:///runner/_work/_actions/coder/start-workspace-action/xxxxxxxx/dist/index.js:30544:22)
    at async StartWorkspaceAction.execute (file:///runner/_work/_actions/coder/start-workspace-action/xxxxxxxx/dist/index.js:30579:22)
    at async main (file:///runner/_work/_actions/coder/start-workspace-action/xxxxxxxx/dist/index.js:30640:3)
    at async file:///runner/_work/_actions/coder/start-workspace-action/xxxxxxxx/dist/index.js:30643:3 {
  status: 406,
  request: {
    method: 'GET',
    url: 'https://github.xxxxxxxx.com//users/rbarak',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/21.1.1 octokit-core.js/6.1.4 Node.js/20.19.3 (linux; x64)',
      authorization: 'token [REDACTED]'
    },
    request: { hook: [Function: bound bound register] }
  },
  response: {
    url: 'https://github.xxxxxxxx.com/login?return_to=https%3A%2F%2Fgithub.xxxxxxxx.com%2Fusers%2Frbarak',
    status: 406,
    headers: {
      'cache-control': 'no-store',
      'content-security-policy': "default-src 'none'; base-uri 'self'; child-src github.xxxxxxxx.com/assets-cdn/worker/; connect-src 'self' github.xxxxxxxx.com www.githubstatus.com api.githubcopilot.com objects-origin.githubusercontent.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://github.xxxxxxxx.com; font-src 'self'; form-action 'self' github.xxxxxxxx.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src 'self'; img-src * data:; manifest-src 'self'; media-src github.xxxxxxxx.com; script-src 'self'; style-src 'unsafe-inline' 'self'; upgrade-insecure-requests; worker-src github.xxxxxxxx.com/assets-cdn/worker/",
      'content-type': 'text/html',
      date: 'Wed, 09 Jul 2025 17:39:08 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'set-cookie': '_fi_sess=xxxxxxxx; path=/; secure; HttpOnly; SameSite=Lax',
      'strict-transport-security': 'max-age=31536000; includeSubdomains',
      'transfer-encoding': 'chunked',
      vary: 'X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-request-id': 'xxxxxxxx',
      'x-runtime': '0.008347',
      'x-xss-protection': '0'
    },
    data: ''
  }
}

On a separate note, I noticed some other potential limitations:

  • Looks like the action doesn't work unless it's invoked from a PR. I tried manually kicking it off and received this error: Error: No issue number provided and no issue context available
  • Looks like parameters key is required. I've tried passing in an empty string but it didn't like that. Not needing to provide parameters to create a workspace should be a valid use case.

@hugodutka
Copy link
Collaborator

@renebarak Could you try using https://github.xxxxxxx.com/api/v3 as the GitHub url? I think the /api/v3 suffix may be necessary for enterprise instances.

Looks like the action doesn't work unless it's invoked from a PR

The action must currently be used in an issue context. It was meant to be triggered by a user tagging @coder in an issue comment, although it would make sense to also make it work without this requirement in a future release.

Not needing to provide parameters to create a workspace should be a valid use case.

Good feedback, thanks!

@renebarak
Copy link
Author

Still no luck, I get the same error.

@hugodutka
Copy link
Collaborator

hugodutka commented Jul 10, 2025

@renebarak I modified my PR to get the GitHub instance URL from the GitHub Actions context instead of action input. Hopefully that fixes the issue - could you try it out?

# ...
    steps:
      - name: Start Coder workspace
        uses: coder/start-workspace-action@3fcbf2de2fc4d361f1c0e1afb7e0961cbea8859f
# ...    

@renebarak
Copy link
Author

Thanks, @hugodutka. Progress but running into a different error now:

UserFacingError: No matching Coder user found for GitHub user @rbarak. Please connect your GitHub account with Coder and try again: https://coder.prod.xxxxxxxx.com/settings/external-auth

We have external authentication configured with our Enterprise GitHub and I have already authenticated. If I try to manually create a workspace in Coder, it shows as authenticated and is not prompting me to authenticate. I can also confirm the same username exists in Coder.

@hugodutka
Copy link
Collaborator

Ah, I see. This is a limitation of Coder itself at the moment. Our HTTP API only allows looking up users by their github.com user ID, and not by github enterprise ids. I'll open an issue about this. I know it's not an ideal solution, but in the meantime you can use the coder-username input to the action instead of github-username.

@hugodutka
Copy link
Collaborator

For reference, I created an issue in coder/coder to track this.

@renebarak
Copy link
Author

Great, missed that input, makes it even easier. I can confirm I have successfully created a workspace from the version you shared. Please let me know when it makes it to the official release.

Thank you for making this change!

@hugodutka
Copy link
Collaborator

@renebarak v0.2.0 is released.

@hugodutka hugodutka closed this Jul 10, 2025
@renebarak renebarak deleted the feat/custom-github-url branch July 10, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants