peter-evans / create-or-update-comment

A GitHub action to create or update an issue or pull request comment
MIT License
706 stars 113 forks source link

There is an issues related to permission occurred #238

Closed abhi6774 closed 1 year ago

abhi6774 commented 1 year ago

Run peter-evans/create-or-update-comment@v3 with: issue-number: 5 body: This is a multi-line test comment

RequestError [HttpError]: Resource not accessible by integration at /home/runner/work/_actions/peter-evans/create-or-update-comment/v3/dist/index.js:4694:21 at processTicksAndRejections (node:internal/process/task_queues:96:5) { status: 403, response: { url: 'https://api.github.com/repos/glxymesh/track/issues/5/comments', status: 403, headers: { 'access-control-allow-origin': '*', 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset', connection: 'close', 'content-encoding': 'gzip', 'content-security-policy': "default-src 'none'", 'content-type': 'application/json; charset=utf-8', date: 'Mon, 07 Aug 2023 06:18:53 GMT', 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', server: 'GitHub.com', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'transfer-encoding': 'chunked', vary: 'Accept-Encoding, Accept, X-Requested-With', 'x-content-type-options': 'nosniff', 'x-frame-options': 'deny', 'x-github-api-version-selected': '2022-11-28', 'x-github-media-type': 'github.v3; format=json', 'x-github-request-id': '6109:0CE9:17A4203:303D8D7:64D08CCD', 'x-ratelimit-limit': '1000', 'x-ratelimit-remaining': '996', 'x-ratelimit-reset': '1691391950', 'x-ratelimit-resource': 'core', 'x-ratelimit-used': '4', 'x-xss-protection': '0' }, data: { message: 'Resource not accessible by integration', documentation_url: 'https://docs.github.com/rest/issues/comments#create-an-issue-comment' } }, request: { method: 'POST', url: 'https://api.github.com/repos/glxymesh/track/issues/5/comments', headers: { accept: 'application/vnd.github.v3+json', 'user-agent': 'octokit-core.js/3.6.0 Node.js/16.16.0 (linux; x64)', authorization: 'token [REDACTED]', 'content-type': 'application/json; charset=utf-8' }, body: '{"body":"This is a multi-line test comment\n- With GitHub Markdown :sparkles:\n- Created by create-or-update-comment\n\n1: https://github.com/peter-evans/create-or-update-comment"}', request: { agent: Agent { _events: [Object: null prototype] { free: [Function (anonymous)], newListener: [Function: maybeEnableKeylog] }, _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object: null prototype] { path: null }, requests: [Object: null prototype] {}, sockets: [Object: null prototype] {}, freeSockets: [Object: null prototype] {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, scheduling: 'lifo', maxTotalSockets: Infinity, totalSocketCount: 0, maxCachedSessions: 100, _sessionCache: { map: { 'api.github.com:443:::::::::::::::::::::': [Buffer [Uint8Array]] }, list: [ 'api.github.com:443:::::::::::::::::::::' ] },

  },
  hook: [Function: bound bound register]
}

} }

spilliams commented 1 year ago

I resolved this by adding the following to my job:

jobs:
  prepare-pr-comment:
    permissions:
      pull-requests: write
    ...
rharkor commented 1 year ago

Still have the problem

peter-evans commented 1 year ago

There is a note in the readme about this error here: https://github.com/peter-evans/create-or-update-comment#action-inputs

Note: In public repositories this action does not work in pull_request workflows when triggered by forks. Any attempt will be met with the error, Resource not accessible by integration. This is due to token restrictions put in place by GitHub Actions. Private repositories can be configured to enable workflows from forks to run without restriction. See here for further explanation. Alternatively, use the pull_request_target event to comment on pull requests.

abhi6774 commented 1 year ago

The issue is resolved by converting the repository from private to public.