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

GitHub Enterprise support #26

Open
gaborho opened this issue Sep 26, 2022 · 2 comments
Open

GitHub Enterprise support #26

gaborho opened this issue Sep 26, 2022 · 2 comments

Comments

@gaborho
Copy link

gaborho commented Sep 26, 2022

Hi, is this action comptabile with GitHub Enterprise? When I try to use it, I receive the following error:

ℹ  info      Creating tree
Error: Bad credentials

✖  fatal     HttpError: Bad credentials 
    at /mnt/data/actions-runner/_work/_actions/internal-marketplace/build-and-tag-action/v2/dist/index.js:4476:23
    at processTicksAndRejections (internal/process/task_queues.js:[9](https://code.rbi.tech/raiffeisen/wzhgaho-merlin-gha-helper/runs/307969?check_suite_focus=true#step:5:10)7:5)
    at async Object.createCommit [as default] (/mnt/data/actions-runner/_work/_actions/internal-marketplace/build-and-tag-action/v2/dist/index.js:17383:18)
    at async buildAndTagAction (/mnt/data/actions-runner/_work/_actions/internal-marketplace/build-and-tag-action/v2/dist/index.js:17492:20)

My configuration:

name: publish

on:
  release:
    types: [published, edited]

env:
  NODE_EXTRA_CA_CERTS: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem

jobs:
  publish:
    runs-on: [ self-hosted, build-testtenant ]
    permissions: write-all
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.release.tag_name }}
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - name: Install deps and build
        run: npm ci && npm run build
      - uses: internal-marketplace/build-and-tag-action@v2
        env:
          DEBUG: '*'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I'm pretty sure I hand over correctly the token. The issue is somewhere here, with the createTree API.

https://github.com/JasonEtco/build-and-tag-action/blob/main/src/lib/create-commit.ts#L11

Should this action work with GHES 3.6?

Thank you.

@gaborho
Copy link
Author

gaborho commented Sep 26, 2022

After adding NODE_DEBUG: http environment variable to my workflow, I can clearly see that the action is talking to api.github.com and not to my GHES instance. I tried to set GITHUB_API_URL as this commit suggests, but did not helped.
Can you please add GHES support @JasonEtco ?

@cpitchford
Copy link

I've got this working and interacting with my GitHub Enterprise Server, but its not only a fix here.

Working backwards, this code relies on https://github.com/JasonEtco/actions-toolkit where we use the run method here:

Toolkit.run(buildAndTagAction, {

The constructor then create the github property using the Octokit class here: https://github.com/JasonEtco/actions-toolkit/blob/c6c7208c521db3b7418dbc9cf5eab282a501250e/src/index.ts#L142

This Octokit object was the issue, it doesn't know how to reach my GitHub Enterprise Server

In my copy of the code, I changed this

    this.github = new Octokit({ auth: `token ${this.token}` })

becomes

this.github = new Octokit({
  auth: `token ${this.token}`,
  baseUrl:  `${process.env.GITHUB_URL}api/v3`
})

With this change, the Octokit object now knows how to reach my 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