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

Make an API call to a self-hosted/enterprise instance #428

Closed
robandpdx opened this issue Oct 20, 2023 · 0 comments · Fixed by #429
Closed

Make an API call to a self-hosted/enterprise instance #428

robandpdx opened this issue Oct 20, 2023 · 0 comments · Fixed by #429
Labels
enhancement New feature or request

Comments

@robandpdx
Copy link
Contributor

robandpdx commented Oct 20, 2023

Is your feature request related to a problem? Please describe.
Users would like to make API calls to a self-hosted instance of GitHub Enterprise Server using this action. Currently that is not possible by setting GITHUB_API_URL, as this environment variable is not honored. To demonstrate this issue, use the following workflow...

name: Test

on:
  workflow_dispatch:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    env:
      GHES_API_URL: https://my.github-enterprise-server.com/api/v3

    steps:
      - name: Demonstrate GITHUB_API_URL
        uses: actions/github-script@v6
        env:
          GITHUB_API_URL: ${{ env.GHES_API_URL }}
        with:
          github-token: xxxxx
          script: |
            console.log(`Demonstrate the resolution of GITHUB_API_URL environment variable...`);
            console.log(`GITHUB_API_URL: ${process.env.GITHUB_API_URL}`);

The log of this workflow shows that the GITHUB_API_URL is set to https://api.github.com/ despite being explicitly set otherwise in the workflow. Here is the output...

Run actions/github-script@v6
  with:
    github-token: xxxxx
    script: console.log(`Demonstrate the resolution of GITHUB_API_URL environment variable...`);
  console.log(`GITHUB_API_URL: ${process.env.GITHUB_API_URL}`);
  
    debug: false
    user-agent: actions/github-script
    result-encoding: json
    retries: 0
    retry-exempt-status-codes: 400,401,403,404,4[2](https://github.com/robandpdx/junk/actions/runs/6589941226/job/17905485324#step:2:2)2
  env:
    GHES_API_URL: https://my.github-enterprise-server.com/api/v[3](https://github.com/robandpdx/junk/actions/runs/6589941226/job/17905485324#step:2:3)
    GITHUB_API_URL: https://my.github-enterprise-server.com/api/v3
Demonstrate the resolution of GITHUB_API_URL environment variable...
GITHUB_API_URL: https://api.github.com/

This was previously discussed in #150 and in #151. However the proposed solution in #151 does not work, as demonstrated above.

Describe the solution you'd like
Adding an optional BASE_URL as proposed in #151 would solve this issue.

Describe alternatives you've considered
I have forked this repo and added the needed option. However, others would benefit from this change as well

Additional context
Nothing to see here.

@joshmgross joshmgross added the enhancement New feature or request label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants