Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

fix error: "Aborted: could not find any git remote pointing to a GitHub repository" #93

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

hrtshu
Copy link
Contributor

@hrtshu hrtshu commented Jun 22, 2022

Error details

I faced below error on GitHub Actions.

From https://github.com/foo/bar
 * [new branch]            some_branch           -> some_branch
  some_branch                                                  xxxxxxxxxx foobar
  remotes/origin/some_branch                                   xxxxxxxxxx foobar
hub pull-request   -b main   -h deploy_foobar   --no-edit   -m "$(cat /github/workspace/pr_create_bot_title.txt) to $(cat /github/workspace/env_dev_branch.txt | sed -e 's/deploy_//g')" -m "$(cat /github/workspace/pr_create_bot_body.txt | sed -e 's/"//g')" -l "automerge"   || true
Aborted: could not find any git remote pointing to a GitHub repository

I looked into this error and found that it occurs in the following part of the hub command.
https://github.com/github/hub/blob/363513a0f822a8bde5b620e5de183702280d4ace/github/localrepo.go#L256

Finally, I found that below error occured.
https://github.com/github/hub/blob/363513a0f822a8bde5b620e5de183702280d4ace/git/url.go#L26

parse "https://some-github-app[bot]:xxxxxxxxxx@github.com/foo/bar": net/url: invalid userinfo

According to RFC3986, the use of [ and ] is not allowed in userinfo subcomponent of an URL.
(ref: https://www.ietf.org/rfc/rfc3986.txt "3.2.1. User Information")

GITHUB_ACTOR environment variable may contain [ or ], such as github-pages[bot].

Thus, the following line produces an invalid URL.

git remote set-url origin "https://$GITHUB_ACTOR:$GITHUB_TOKEN@${GITHUB_SERVER_URL#https://}/$GITHUB_REPOSITORY"

Suggestion

I found the GitHub official documentation that describe the repository url of below format.

https://x-access-token:<token>@github.com/owner/repo.git

https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#http-based-git-access-by-an-installation

So I have modified it as such.

Presumably, when using tokens for git / hub command, any user name will work.

@hrtshu
Copy link
Contributor Author

hrtshu commented Jun 24, 2022

@wei
Thank you for providing this very useful action.
I found a bug and fixed it. Please review.

@wei
Copy link
Member

wei commented Jun 24, 2022

Hey @heiskr would you be able to review and deploy this? Not sure what the current deploy workflow is.

@heiskr heiskr merged commit ff8726a into repo-sync:master Jun 24, 2022
@hrtshu
Copy link
Contributor Author

hrtshu commented Jun 24, 2022

@heiskr
Thank you for reviewing and merging quickly!
Do you have plan to release this change?

@hrtshu
Copy link
Contributor Author

hrtshu commented Jul 20, 2022

@heiskr
Would you please release this change early?

You merged it into the master branch, but it hasn't been released to GitHub Action, so this change isn't available yet.

I need this change as soon as possible, but if it's difficult to release immediately, I'd like to consider another option.

I know you’re busy. Thank you.

@wei
Copy link
Member

wei commented Oct 31, 2022

@allcontributors add @hrtshu for code

@allcontributors
Copy link
Contributor

@wei

I've put up a pull request to add @hrtshu! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants