Skip to content
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

Checkout does not work when the server is configured with a sub-path #1370

Closed
psa opened this issue Jun 4, 2023 · 10 comments
Closed

Checkout does not work when the server is configured with a sub-path #1370

psa opened this issue Jun 4, 2023 · 10 comments

Comments

@psa
Copy link

psa commented Jun 4, 2023

I have a Gitea server configured with sub-paths (e.g. htttp://example.com/path/to/git/owner/repository.git). Checkout attempts to checkout https://example.com/owner/repository.git and throws away the sub-path.

How to replicate:

  • Setup a Gitea server (or any other supported git server) behind a reverse proxy with a sub-path
  • Have an action which uses actions/checkout
  • Watch the logs and see that the called URL is missing the sub-path.

My best guess is that it's lost in https://github.com/actions/checkout/blob/f095bcc56b7c2baf48f3ac70d6d6782f4f553222/src/url-helper.ts#LL19C1-L19C1 as, according to the comment, serviceUrl.origin is SCHEME://HOSTNAME[:PORT]

@RouxAntoine
Copy link

RouxAntoine commented Jul 7, 2023

Hello i came to the same conclusion as you. and that pretty sad, do you have found a workaround ?

@RouxAntoine
Copy link

RouxAntoine commented Jul 9, 2023

tag on a fork with a fix https://github.com/RouxAntoine/checkout/tree/v3.5.4

@kdumontnu
Copy link

Thanks for reporting & the proposed fix. I can confirm your patch fixed the bug for me. Looking forward to seeing it get merged 🤞

@RouxAntoine
Copy link

RouxAntoine commented Aug 2, 2023

Your welcome, I hope too, however I am afraid of the number of issues and pull request on a so used and so small action.

@frankli0324
Copy link

frankli0324 commented Aug 10, 2023

I believe this issue is a dulplicate #1242
also the PR is also dulplicated: #1305 @RouxAntoine

@RouxAntoine
Copy link

RouxAntoine commented Aug 10, 2023

indeed it seems, I close mine 🙂, moreover I am not totaly sure that the regex parsing is necessary

export function getBaseUrl(url: string): string {
  const matcher = url.match(/^[^?]+/)
  return (matcher && matcher[0].replace(/\/+$/g, '')) || ''
}

@frankli0324
Copy link

frankli0324 commented Aug 10, 2023

https://instance.com/test/?region=asdf, I think removing the trailing / is generally a good practice, especially for this kind of url that often comes with concatenation?

@RouxAntoine
Copy link

not totally sure, but if yes, so :

export function trimEndingSlash(input: string): string {
  return input.replace(/\/$/, "");
}

My point is here is no reason to parse serverUrl.href this should be kept simple and use attribute pathname of Object URL https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname

@OdinVex
Copy link

OdinVex commented Aug 27, 2023

This repository is a clone of Gitea's Action Checkout with the sub-path fix: https://gitea.com/ScMi1/checkout

@joshmgross
Copy link
Member

joshmgross commented Oct 20, 2023

Closing as duplicate of #1242, which we're not planning to support at this time.

@joshmgross joshmgross closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2023
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

No branches or pull requests

6 participants