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

Deployment URL cannot be parsed for GitHub Enterprise #865

Open
jensvandenreyt opened this issue Feb 8, 2023 · 2 comments
Open

Deployment URL cannot be parsed for GitHub Enterprise #865

jensvandenreyt opened this issue Feb 8, 2023 · 2 comments

Comments

@jensvandenreyt
Copy link

jensvandenreyt commented Feb 8, 2023

Problem

The deployment URL for GitHub Enterprise cannot be parsed. As a result, ParseDeploymentURL in pkg/github/deployment.go will always return nil and deployment statuses in GitHub will never be updated when phases change.

var patternDeploymentURL = regexp.MustCompile(`^https://api\.github\.com/repos/(.+?)/(.+?)/deployments/(\d+)$`)
// ParseDeploymentURL parses the URL.
// For example, https://api.github.com/repos/int128/sandbox/deployments/422988781
func ParseDeploymentURL(s string) *Deployment {
m := patternDeploymentURL.FindStringSubmatch(s)
if len(m) != 4 {
return nil
}

As an example, our GitHub Enterprise URL https://api.github.some-company.com/repos/IOTA/repo/deployments/54392 will never match the regex.

This also does not seem to be the only place the issue occurs. In pkg/github/types.go there are also some hardcoded regexes for the public github.com.

var (
patternRepositoryHTTPS = regexp.MustCompile(`^https://github\.com/([^/]+?)/([^/]+?)(\.git)?$`)
patternRepositorySSH = regexp.MustCompile(`^git@github\.com:([^/]+?)/([^/]+?)(\.git)?$`)
)

Edit
I just discovered that the issue also occurs in https://github.com/int128/oauth2-github-app. The config.go file also has the hardcoded public github.com URL.

Solution

Can the regex either be made less strict on the hostname, or be constructed using the GITHUB_ENTERPRISE_URL from the secret?

@int128
Copy link
Owner

int128 commented Feb 18, 2023

Thank you for bringing up the issue. I will fix the implementation for GitHub Enterprise Server.

@int128
Copy link
Owner

int128 commented Feb 18, 2023

@jensvandenreyt Can you check #878?
Let me clarify if it meets the requirement because I don't have an environment of GitHub Enterprise Server.

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

2 participants