fitomad / github-chatgpt-integration

How to integrate ChatGPT with a GitHub repository using GitHub Actions in order to perform automated code reviews for every pull request
7 stars 6 forks source link

Trying to setup permissions! #26

Open MrHinsh opened 1 month ago

MrHinsh commented 1 month ago

I get an error when using a GitHub application to create a token.

code-review:
  name: "Code Review Bot"
  runs-on: ubuntu-latest
  needs: [Setup]
  if: ${{ github.event_name == 'pull_request' }}
  steps:
    - uses: actions/create-github-app-token@v1
      id: app-token
      with:
        app-id: ${{ env.APP_ID }}
        private-key: ${{ env.PRIVATE_KEY }}
    - uses: fitomad/github-chatgpt-integration@main
      with:
        openai-api-key: ${{ secrets.OPENAI_API_KEY }}
        github-token: ${{ secrets.GH_TOKEN }}
        github-pr-id: ${{ github.event.number }}
        dev-lang: c#
        openai-max-tokens: 4096

with the following result:

/usr/bin/docker run --name b1871d6be1f808aeba4a01861a241b42b48509_332574 --label b1871d --workdir /github/workspace --rm -e "APP_ID" -e "PRIVATE_KEY" -e "INPUT_OPENAI-API-KEY" -e "INPUT_GITHUB-TOKEN" -e "INPUT_GITHUB-PR-ID" -e "INPUT_DEV-LANG" -e "INPUT_OPENAI-MAX-TOKENS" -e "INPUT_OPENAI-ENGINE" -e "INPUT_OPENAI-TEMPERATURE" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/azure-devops-migration-tools/azure-devops-migration-tools":"/github/workspace" b1871d:6be1f808aeba4a01861a241b42b48509  "***" "***" "2182" "c#" "gpt-3.5-turbo" "0.0" "4096"
Traceback (most recent call last):
  File "/main.py", line 89, in <module>
    code_review(parameters=review_parameters)
  File "/main.py", line [15](https://github.com/nkdAgility/azure-devops-migration-tools/actions/runs/9958914675/job/27514491187#step:4:16), in code_review
    pull_request.create_issue_comment(resume)
  File "/usr/local/lib/python3.9/site-packages/github/PullRequest.py", line 467, in create_issue_comment
    headers, data = self._requester.requestJsonAndCheck(
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 398, in requestJsonAndCheck
    return self.__check(
  File "/usr/local/lib/python3.9/site-packages/github/Requester.py", line 423, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 403 {"message": "Resource not accessible by integration", "documentation_url": "https://docs.github.com/rest/issues/comments#create-an-issue-comment", "status": "403"}

and the following permissions:

image

Any idea why I cant use a bot?

fitomad commented 1 month ago

Sorry for the delay @MrHinsh

Did you check that your GitHub Developer token is properly set on the GitHub repo?