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

wrong URL for GitHub Enterprise repos #831

Closed
christian-rauch opened this issue Oct 24, 2023 · 3 comments · Fixed by #835
Closed

wrong URL for GitHub Enterprise repos #831

christian-rauch opened this issue Oct 24, 2023 · 3 comments · Fixed by #835
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@christian-rauch
Copy link
Contributor

Description

The GitHub uses the wrong URL to fetch the repo from a GitHub Enterprise instance.

Expected Behavior

The checked-out repo URL should be the same as the repo where the action is running.

Actual Behavior

The checked-out repo is assumed to be hosted at "https://github.com/some/repo.git".

To Reproduce

The setup is as follows:

A repo is hosted in a GitHub Enterprise instance, assuming https://git.COMPANY.com/ORG/ros_package.git. In this repo, I am trying to run the CI with:

    - uses: ros-tooling/action-ros-ci@v0.3
      with:
        package-name: ros_package
        target-ros2-distro: foxy
        import-token: "${{ secrets.MY_SECRET_TOKEN }}"

This action is creating a package.repo and trying to import it:

bash -c,vcs import --force --recursive src/ < package.repo

But this fails with something like

  Could not determine ref type of version: remote: Invalid username or password.
  fatal: Authentication failed for 'https://github.com/ORG/ros_package.git/'

Showing the content of package.repo indeed shows something like:

./ros_ws/package.repo
repositories:
  y9gr4zea6r/fairy_ros:
    type: git
    url: 'https://github.com/ORG/ros_package.git'

Instead of using the URL of the repo that the action runs in, it is replacing the enterprise URL with the public GitHub instance.

@christian-rauch christian-rauch added the bug Something isn't working label Oct 24, 2023
@christian-rauch
Copy link
Contributor Author

christian-rauch commented Oct 24, 2023

The issue is here:

type: git
url: 'https://github.com/${repoFullName}.git'
version: '${commitRef}'`;

Instead of hardcoding https://github.com, the URL should come from the environment variable GITHUB_SERVER_URL.

See also: https://docs.github.com/en/enterprise-cloud@latest/actions/creating-actions/about-custom-actions#compatibility-with-github-enterprise-server:

To ensure that your action is compatible with GitHub Enterprise Server, you should make sure that you do not use any hard-coded references to GitHub API URLs. You should instead use environment variables to refer to the GitHub API:

  • For the REST API, use the GITHUB_API_URL environment variable.
  • For GraphQL, use the GITHUB_GRAPHQL_URL environment variable.

@christophebedard
Copy link
Member

Thanks for reporting this. A PR would definitely be welcome 😁

@christian-rauch
Copy link
Contributor Author

Thanks for reporting this. A PR would definitely be welcome 😁

See #835.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants