Skip to content

GitHub Enterprise support #26

Description

@gaborho

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.

Activity

  1. gaborho commented on Sep 26, 2022

    @gaborho
    Author

    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 ?

  2. cpitchford commented on Jun 13, 2023

    @cpitchford

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions