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

Enterprise Github Support #89

Closed
Drjacky opened this issue Jan 26, 2025 · 23 comments · Fixed by #93
Closed

Enterprise Github Support #89

Drjacky opened this issue Jan 26, 2025 · 23 comments · Fixed by #93
Labels
enhancement New feature or request

Comments

@Drjacky
Copy link

Drjacky commented Jan 26, 2025

Is your feature request related to a problem? Please describe.
It might be; I'm not sure how to define the username if the user is on github enterprise.

Describe the solution you'd like
I want to set the action on my personal github(github.com) to generate the contribution chart for my work github(github.mycompany.com). My company's enterprise github doesn't support actions.

Describe alternatives you've considered
I created this workflow in the work github but for some reason, it doesn't access to the private repos. I tried to add GITHUB_TOKEN to secrets but github raised an error that secrets cannot start with GITHUB_. anyway, because my company's enterprise github doesn't support actions, I cannot generate the SVH over there.

@yoshi389111 yoshi389111 added the question Further information is requested label Mar 5, 2025
@yoshi389111
Copy link
Owner

@Drjacky
Thank you for your question.

Currently, github-profile-3d-contrib does not support Github Enterprise.

From what I can see in the Github Enterprise documentation, it seems to support the same API (GraphQL), so if there are no restrictions on the Github Enterprise side, it may be possible to just change the API destination and have it work without any other modifications.

However, I don't have the environment to check and can't provide immediate support.

If you want to fork github-profile-3d-contrib, modify it, and test it, the place to modify is the URL near the top of src/github-graphql.ts (the destination URL is just a guess).

- export const URL = 'https://api.github.com/graphql';
+ export const URL = 'https://api.github.mycompany.com/graphql';

but github raised an error that secrets cannot start with GITHUB_.

The GITHUB_TOKEN secret is created automatically by GitHub.

User-created secrets cannot start with GITHUB_.

Create your own secret and set it in the GITHUB_TOKEN environment variable.

For example, if you created a secret with a name like MY_PERSONAL_ACCESS_TOKEN, it would look like this:

          env:
-           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+           GITHUB_TOKEN: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}

Please also see Issue #60.

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Thanks for your attention!

I cloned your repo (because my company's enterprise doesn't allow to have secrets environment, so I cloned and pushed the repo as private)
And this is my yml:

name: GitHub-Enterprise-Profile-3D-Contrib

on:
  schedule: # 03:00 JST == 18:00 UTC
    - cron: "0 18 * * *"
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    name: generate-github-enterprise-profile-3d-contrib
    steps:
      - uses: actions/checkout@v3
      - uses: Drjacky/github-profile-3d-contrib@0.7.1
      # I even used - uses: Drjacky/github-enterprise-profile-3d-contrib@0.7.1
        env:
          GITHUB_TOKEN: ${{ secrets.MY_COMPANY_PERSONAL_ACCESS_TOKEN }}
          USERNAME: ${{ github.repository_owner }}
          SETTING_JSON: ./profile-3d-contrib/ever-green-custom.json
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10' 
      - run: python ./bin/change-border.py profile-3d-contrib/profile-custom-evergreen.svg profile-3d-contrib/profile-custom-evergreen-with-border.svg
      - name: Commit & Push
        run: |
          git config user.name github-actions
          git config user.email github-actions@github.mycompany.com
          git add -A .
          git commit -m "3d-contrib generated"
          git push

But I get:

Missing download info for Drjacky/github-profile-3d-contrib@0.7.1

or

Missing download info for Drjacky/github-enterprise-profile-3d-contrib@0.7.1

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Even when I forked, it still throws

Missing download info for Drjacky/github-business-profile-3d-contrib@0.7.1

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Okay, that Missing download info is gone; was due to lack of release in my fork.
But now:

Run Drjacky/github-business-profile-3d-contrib@0.7.2
AxiosError: Request failed with status code 401
at settle (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:189199:12)
at IncomingMessage.handleStreamEnd (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:190316:11)
at IncomingMessage.emit (node:events:531:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:191426:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async fetchFirst (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:1406:22)
at async Object.fetchData (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:1445:18)
at async main (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:1528:26) {
code: 'ERR_BAD_REQUEST',
....
data: {
message: 'Bad credentials',
documentation_url: 'https://docs.github.com/graphql',
status: '401'
}
},
status: 401
}

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

I tried both

https://github.mycompany.com/api/graphql
&
https://api.github.mycompany.com/graphql

and still:

data: {
message: 'Bad credentials',
documentation_url: 'https://docs.github.com/graphql',
status: '401'
}
},
status: 401

@yoshi389111
Copy link
Owner

To help me understand, let me go through the prerequisites.

  • Github Actions is disabled in your company's Github Enterprise.
  • You want to create a company contribution image with your personal Github account. (github.com/Drjacky)
  • You can access your company's Github Enterprise server from Github Actions on github.com via the Internet.

Is the above correct?

In that case, you first need to do the following with your company account.

  1. Create a personal access token with your company's Github Enterprise account.

Next, modify github-profile-3d-contrib.

  1. Fork my github-profile-3d-contrib repository and create github.com/Drjacky/github-profile-3d-contrib.
  2. Change the destination URL of the forked source to your company's Github Enterprise (this is the modification mentioned above).
  3. Build the modified version above.

If possible, you should run it locally to make sure it works correctly.

How to run it locally (Linux, Windows WSL2, etc.) is written in README.md.

  • While not required, it may be a good idea to build and make sure it works properly before changing the URL.

Finally, to run Github Actions, create a workflow (YAML file) in a github.com repository.

  1. Prepare a repository to run Github Actions. (for example, add a workflow YAML file to github.com/Drjacky/Drjacky)
  2. Create the workflow YAML file in that repository to run github.com/Drjacky/github-profile-3d-contrib.
  3. Create a secret MY_COMPANY_PERSONAL_ACCESS_TOKEN in that repository and set your company's personal access token.

If your company's account name is also Drjacky, your YAML file would look like this:

      - uses: Drjacky/github-profile-3d-contrib@0.7.1 # <- personal account repo.
        env:
          GITHUB_TOKEN: ${{ secrets.MY_COMPANY_PERSONAL_ACCESS_TOKEN }}
          USERNAME: Drjacky # <- company account name

@yoshi389111
Copy link
Owner

The GraphQL endpoint for Github Enterprise is http(s)://HOSTNAME/api/graphql, so https://github.mycompany.com/api/graphql seems to be correct.

https://docs.github.com/en/enterprise-server@3.11/graphql/guides/forming-calls-with-graphql

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

  • Github Actions is disabled in your company's Github Enterprise.
    Yes

  • You want to create a company contribution image with your personal Github account. (github.com/Drjacky)
    with my Personal Token that I created in my Company Enterprise Github account. (github.mycompany.com/myusername)

  • You can access your company's Github Enterprise server from Github Actions on github.com via the Internet.
    -Not sure what does it mean? I can access github.mycompany.com/myusername via browser.

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

https://github.mycompany.com/api/graphql

Correct. I tried this one as well and still...

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Looks like we cannot access Github Enterprise from Github.com; it still redirects the request to: https://api.github.com/graphql

Run Drjacky/github-business-profile-3d-contrib@0.7.2
AxiosError: Request failed with status code 401
    at settle (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:189199:12)
    at IncomingMessage.handleStreamEnd (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:19031[6](https://github.com/Drjacky/Drjacky/actions/runs/13738454743/job/38424924638#step:3:7):11)
    at IncomingMessage.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at Axios.request (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.[7](https://github.com/Drjacky/Drjacky/actions/runs/13738454743/job/38424924638#step:3:8).2/dist/index.js:191426:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async fetchFirst (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:1406:22)
    at async Object.fetchData (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:1445:1[8](https://github.com/Drjacky/Drjacky/actions/runs/13738454743/job/38424924638#step:3:9))
    at async main (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/0.7.2/dist/index.js:1528:26) {
  code: 'ERR_BAD_REQUEST',
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [ 'xhr', 'http', 'fetch' ],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function [FormData]], Blob: [class Blob] },
    validateStatus: [Function: validateStatus],
    headers: Object [AxiosHeaders] {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      Authorization: 'bearer ***',
      'User-Agent': 'axios/1.8.1',
      'Content-Length': '648',
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    method: 'post',
    url: 'https://api.github.com/graphql',
    data: '{"query":" query($login: String!)
.
.
.
data: {
      message: 'Bad credentials',
      documentation_url: 'https://docs.github.com/graphql',
      status: '401'
    }
  },
  status: 401

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

And I do have Actions in company's enterprise github but, when I run your Repo Action there, it stuck at

Requested labels: self-hosted
Job defined at: mycompanyusername/mycompanyusername/.github/workflows/profile-3d.yml@refs/heads/main
Waiting for a runner to pick up this job...

@yoshi389111
Copy link
Owner

I looked at the repository and found two issues.

  1. The build result is not being pushed to the server. This tool is written in Typescript, so it needs to be built. When you build, the files under dist/ are updated, so you need to push them.
  2. Sorry, I forgot that the build result will not be used if the tag remains at 0.7.1. Once you build and push, create a new tag or note the commit hash. Then specify that tag or commit hash in your workflow YAML file.
  • If you created a new tag new-tag, specify @new-tag instead of @0.7.1.
  • If you wrote down the commit hash, for example if the commit hash is 83b7061638ee4956cf7545a6f7efe594e5ad0241 then specify @83b7061638ee4956cf7545a6f7efe594e5ad0241.

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

If by build, you mean release, yes, I did on every single change I had/tried on TS file.
So, I delete old release (0.7.2) and created the SAME 0.7.2, everytime I was having a new change in the TS file.

Does this work? -> I delete the previous release (and now there is no release) and create a new release But using the same TAG name and same ReleaseTitle.

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Nah, you're right. If I even delete the release and use the same Tag and same Title, it still has the old code.
I used 0.7.2 again and downloaded the sourcecoude.zip and both src and dist had old URL

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Now I'm using the last commit hash and still the same:

Run Drjacky/github-business-profile-3d-contrib@bf2ce0ce278495d02d45252385a6df4a907c4e04
env:
    GITHUB_TOKEN: ***
    USERNAME: ***
    SETTING_JSON: ./profile-[3](https://github.com/Drjacky/Drjacky/actions/runs/13738893509/job/38425822090#step:3:3)d-contrib/ever-green-custom.json
AxiosError: Request failed with status code [4](https://github.com/Drjacky/Drjacky/actions/runs/13738893509/job/38425822090#step:3:4)01
AxiosError: Request failed with status code 401
    at settle (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/bf2ce0ce278495d02d45252385a[6](https://github.com/Drjacky/Drjacky/actions/runs/13738893509/job/38425822090#step:3:7)df4a907c4e04/dist/index.js:189199:12)
    at IncomingMessage.handleStreamEnd (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/bf2ce0ce2[7](https://github.com/Drjacky/Drjacky/actions/runs/13738893509/job/38425822090#step:3:8)8495d02d45252385a6df4a907c4e04/dist/index.js:190316:11)
    at IncomingMessage.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:[8](https://github.com/Drjacky/Drjacky/actions/runs/13738893509/job/38425822090#step:3:9)2:21)
    at Axios.request (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/bf2ce0ce278495d02d45252385a6df4a907c4e04/dist/index.js:191426:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:[9](https://github.com/Drjacky/Drjacky/actions/runs/13738893509/job/38425822090#step:3:10)5:5)
    at async fetchFirst (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/bf2ce0ce278495d02d45252385a6df4a907c4e04/dist/index.js:1406:22)
    at async Object.fetchData (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/bf2ce0ce278495d02d45252385a6df4a907c4e04/dist/index.js:1445:18)
    at async main (/home/runner/work/_actions/Drjacky/github-business-profile-3d-contrib/bf2ce0ce278495d02d45252385a6df4a907c4e04/dist/index.js:1528:26) {
  code: 'ERR_BAD_REQUEST',
.
.
.
method: 'post',
    url: 'https://api.github.com/graphql',
    data: '{"query":" query($login: String!)
data: {
      message: 'Bad credentials',
      documentation_url: 'https://docs.github.com/graphql',
      status: '401'
    }
  },
  status: 401

@yoshi389111
Copy link
Owner

yoshi389111 commented Mar 8, 2025

Github Actions cannot be run in TypeScript (*.ts) files. They must be converted to JavaScript (*.js) files. This conversion is called building.

To build, you need to install tools such as node.js.

Perhaps you don't have a build environment.

I have now built a temporary modified version and made it accessible under the name yoshi389111/github-profile-3d-contrib@test-enterprise.
The destination URL can now be specified with the environment variable GITHUB_ENDPOINT. Please write the URL directly or set it as a secret and register the secret name.

      - uses: yoshi389111/github-profile-3d-contrib@test-enterprise  # <- changed
        env:
          GITHUB_TOKEN: ${{ secrets.MY_COMPANY_PERSONAL_ACCESS_TOKEN }}
          USERNAME: company-account-name # <- your company account name
          GITHUB_ENDPOINT: https://github.mycompany.com/api/graphql # or secrets  <-- added

Note: This version will be removed later.

Node: Fixed a typo: GITHUB_ENDPINT -> GITHUB_ENDPOINT

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

name: GitHub-Business-Profile-3D-Contrib

on:
  schedule: # 03:00 JST == 18:00 UTC
    - cron: "0 18 * * *"
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    name: generate-github-business-profile-3d-contrib
    steps:
      - uses: actions/checkout@v3
      - uses: yoshi389111/github-profile-3d-contrib@test-enterprise
        env:
          GITHUB_TOKEN: ${{ secrets.MY_COMPANY_PERSONAL_ACCESS_TOKEN }}
          USERNAME: ${{ secrets.MY_COMPANY_USERNAME }}
          GITHUB_ENDPINT: ${{ secrets.MY_COMPANY_ENDPOINT }}
          SETTING_JSON: ./profile-3d-contrib/ever-green-custom.json
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10' 
      - run: python ./bin/change-border.py profile-3d-contrib/profile-custom-evergreen.svg profile-3d-contrib/profile-custom-evergreen-with-border.svg
      - name: Commit & Push
        run: |
          git config user.name github-actions
          git config user.email github-actions@github.mycompany.com
          git add -A .
          git commit -m "3d-contrib generated"
          git push

Result:

Run yoshi389111/github-profile-3d-contrib@test-enterprise
  env:
    GITHUB_TOKEN: ***
    USERNAME: ***
    GITHUB_ENDPINT: 
    SETTING_JSON: ./profile-[3](https://github.com/Drjacky/Drjacky/actions/runs/13738974265/job/38425975827#step:3:3)d-contrib/ever-green-custom.json
  
AxiosError: Request failed with status code [4](https://github.com/Drjacky/Drjacky/actions/runs/13738974265/job/38425975827#step:3:4)01
...
data: {
      message: 'Bad credentials',
      documentation_url: 'https://docs.github.com/graphql',
      status: '401'
    }
  },
  status: 401

@yoshi389111
Copy link
Owner

Sorry, please fix the typo GITHUB_ENDPINT -> GITHUB_ENDPOINT

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Same with:

Run yoshi389111/github-profile-3d-contrib@test-enterprise
  env:
    GITHUB_TOKEN: ***
    USERNAME: ***
    GITHUB_ENDPOINT: 
    SETTING_JSON: ./profile-[3](https://github.com/Drjacky/Drjacky/actions/runs/13738990884/job/38426014149#step:3:3)d-contrib/ever-green-custom.json

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

Can I use git config user.email github-actions@github.mycompany.com, or should it be the same git config user.email github-actions@github.com

@Drjacky
Copy link
Author

Drjacky commented Mar 8, 2025

It worked. I forgot to add the secret to the profile Drjacky repo. 🎉
Thank you so much!!!!!!!

@yoshi389111
Copy link
Owner

I'm glad that it worked.

In the next version, 0.8.0, you will be able to set the Github Enterprise URL with the environment variable GITHUB_ENDPOINT. If not specified, the destination will be github.com as before.

Please note that the current test-enterprise will be deleted after the 0.8.0 release.

@yoshi389111 yoshi389111 added enhancement New feature or request and removed question Further information is requested labels Mar 8, 2025
@yoshi389111
Copy link
Owner

@Drjacky
I just released 0.8.0.

Please change @test-enterprise to @0.8.0.
If you have any problems after changing it, please let me know.

test-enterprise will be removed in a few days.

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