Issues reading diff from within action

Hello! I’m trying to obtain a diff from my action on a private repo and I’m using this piece of code here:

It looks a lot like the example:

    runs-on: ubuntu-latest
      - uses: actions/github-script@v1
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            const diff_url = context.payload.pull_request.diff_url
            const result = await github.request(diff_url)

It’s not working, unfortunately. For some reason the token is not authenticating and I’m receiving a 404 when making that request:

RequestError [HttpError]: Not Found
##[error]Unhandled error: HttpError: Not Found
    at /home/runner/work/_actions/actions/github-script/v1/dist/index.js:9320:23
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v1/dist/index.js:), <anonymous>:4:16)
    at async main (/home/runner/work/_actions/actions/github-script/v1/dist/index.js:) {
  name: 'HttpError',
  status: 404,
  headers: {
    'cache-control': 'no-cache',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'; base-uri 'self'; connect-src 'self'; form-action 'self'; img-src 'self' data:; script-src 'self'; style-src 'unsafe-inline'",
    'content-type': 'text/plain; charset=utf-8',
    date: 'Xxx, 00 XXX 2020 00:00:00 GMT',
    'expect-ct': 'max-age=2592000, report-uri=""',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: '',
    status: '404 Not Found',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    vary: 'X-PJAX, Accept-Encoding, Accept, X-Requested-With',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-request-id': 'BLABLABLA',
    'x-xss-protection': '1; mode=block'
  request: {
    method: 'GET',
    url: '',
    headers: {
      accept: 'application/vnd.github.-preview+json',
      'user-agent': 'actions/github-script octokit.js/16.43.1 Node.js/12.13.1 (Linux 5.3; x64)',
      authorization: 'token [REDACTED]'
    request: { hook: [Function: bound bound register] }

What can I fix to get the full diff? Thanks in advance.

Hi @renata-slalom,

The error is due to the repository is private, it’s failed to request(GET) from ‘’ directly.

github object (eg: github.request()) will access the Octokit API, and headers and other defaults are already set. Please check the doc here for more details:
According to the solution here, you can set header ’ “Accept: application/vnd.github.v3.diff”’ and use Pull_request URL to get the diff for your script.

Or directly use below command to get diff:

curl -i --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' --header "Accept: application/vnd.github.v3.diff"


This is my bad! The example shouldn’t be in the github-script README as-is. @weide-zhou is correct that the right way of getting this is via the GitHub API with the diff content type in the “Accept” header.