auto-assign-action icon indicating copy to clipboard operation
auto-assign-action copied to clipboard

Keep getting Bad_Credentials error

Open thilakpv opened this issue 2 years ago • 6 comments

name: On Open PR Actions

on: pull_request: # types: [opened]

jobs: auto-assign: permissions: write-all runs-on: self-hosted steps: - name: Auto Assign Action uses: kentaro-m/[email protected] with: token: ${{ secrets.GITHUB_TOKEN }}

I keep getting Bad Credentials error despite of token having write permissions. What am I missing?

GITHUB_TOKEN Permissions Actions: write Checks: write Contents: write Deployments: write Discussions: write Issues: write Metadata: read Packages: write Pages: write PullRequests: write RepositoryProjects: write SecurityEvents: write Statuses: write Secret source: Actions Prepare workflow directory Prepare all required actions

Error: Bad credentials

thilakpv avatar Dec 01 '22 18:12 thilakpv

I am also facing the same issue. In my case I am using the GitHub Enterprise Server 3.6.3 and the '2.293.1' runners version. Which permissions need the token to have? Any help on this?

ihmabreu avatar Jan 12 '23 08:01 ihmabreu

@ihmabreu @thilakpv

Hello. This project is set to look at the public github baseUrl by default. Therefore, if you host and use Github Enterprise yourself, you need to modify the code as follows

// src > run.ts

export async function run() {
  try {
    const token = core.getInput('repo-token', { required: true })
    const configPath = core.getInput('configuration-path', { required: true })   
    const client = new github.GitHub(token, {
      baseUrl: "<ENTER_YOUR_GITHUB_ENTERPRISE_API_URL>",  //  ex) https://git.my-company.com/api/v3
    })

   ....
}

After modifying the code, run the following command before pushing.

npm run package

lette1394 avatar Feb 13 '23 14:02 lette1394

@ihmabreu @thilakpv @lette1394

The URL of the API endpoint should normally be changed based on the environment variable (GITHUB_API_URL).

https://docs.github.com/en/actions/creating-actions/about-custom-actions#compatibility-with-github-enterprise-server

However, this action uses a library that does not support GitHub Enterprise Server and communicates with the GitHub API, so API endpoint changes based on environment variables are not available.

Perhaps updating the @actions/github package to v3 or higher will resolve this issue.

https://github.com/actions/toolkit/pull/453

I had worked on this before but never completed it.

https://github.com/kentaro-m/auto-assign-action/pull/63

kentaro-m avatar Feb 14 '23 12:02 kentaro-m

I merged #63 and released these changes as v1.2.5. If it's possible, please try to check this action works with GHE Server.

kentaro-m avatar Feb 19 '23 13:02 kentaro-m

@kentaro-m my team was able to test the new version with GHE Server successfully 💯

ihmabreu avatar Mar 31 '23 11:03 ihmabreu

@kentaro-m Unfortunately it still doesn't work with GHE 😢

luanfonsecap avatar Jun 02 '23 01:06 luanfonsecap