kentaro-m / auto-assign-action

An action which adds reviewers to the pull request when the pull request is opened.
MIT License
298 stars 89 forks source link

Keep getting Bad_Credentials error #101

Open thilakpv opened 1 year ago

thilakpv commented 1 year ago

name: On Open PR Actions

on: pull_request:

types: [opened]

jobs: auto-assign: permissions: write-all runs-on: self-hosted steps:

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

ihmabreu commented 1 year ago

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?

lette1394 commented 1 year ago

@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
kentaro-m commented 1 year ago

@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 commented 1 year ago

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.

ihmabreu commented 1 year ago

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

luanfonsecap commented 1 year ago

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