pascalgn / automerge-action

GitHub action to automatically merge pull requests that are ready
MIT License
847 stars 207 forks source link

ERROR Resource not accessible by integration #236

Open chickenandpork opened 1 year ago

chickenandpork commented 1 year ago

With slight changes from the example config, my PRs are seeing this failure message at subject: ERROR Resource not accessible by integration

Config

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  check_suite:
    types:
      - completed
  status: {}
jobs:
  automerge:
    runs-on: ubuntu-latest
    permissions:
      # actions: read|write|none
      # Note: Advice from https://github.com/pascalgn/automerge-action/issues/214
      contents: write
    steps:
      - id: automerge
        name: automerge
        uses: "pascalgn/automerge-action@v0.15.6"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          MERGE_LABELS: "!wip"
          MERGE_METHOD_LABELS: "automerge=merge,autosquash=squash"
          MERGE_METHOD_LABEL_REQUIRED: true
          MERGE_COMMIT_MESSAGE: "pull-request-description"
          MERGE_RETRIES: "10"
          MERGE_RETRY_SLEEP: "30000"
          MERGE_REQUIRED_APPROVALS: "0"
          UPDATE_LABELS: ""
          UPDATE_METHOD: "rebase"

Detected Labels

$ gh pr view 19 --json labels
{
  "labels": [
    {
      "id": "LA_kwDOKFf69c8AAAABXivleg",
      "name": "automerge",
      "description": "",
      "color": "42EA5A"
    }
  ]
}

Failing Log

Run pascalgn/automerge-action@v0.15.6
  env:
    GITHUB_TOKEN: ***
    MERGE_LABELS: !wip
    MERGE_METHOD_LABELS: automerge=merge,autosquash=squash
    MERGE_METHOD_LABEL_REQUIRED: true
    MERGE_COMMIT_MESSAGE: pull-request-description
    MERGE_RETRIES: 10
    MERGE_RETRY_SLEEP: 30000
    MERGE_REQUIRED_APPROVALS: 0
    UPDATE_LABELS: 
    UPDATE_METHOD: rebase
2023-08-24T18:51:13.219Z INFO  Event name: pull_request
2023-08-24T18:51:13.477Z ERROR Resource not accessible by integration

It would be awesome if the inaccessible Resource was named or identified I think; can you suggest what else I can try?

RoelAdriaans commented 7 months ago

The reason for this is issue #214 , the automation does not have enough rights to your repository. This can be fixed with:

...
    steps:
      - id: automerge
        name: automerge
        uses: "pascalgn/automerge-action@v0.15.6"
        permissions:
          contents: write
...
pascalgn commented 5 months ago

I've updated the README and closed #214, so I think this one can also be closed.

chickenandpork commented 5 months ago

Thanks @pascalgn ; I hope it fixes it. I forget now where I was trying this.

Did you see where I asked:

It would be awesome if the inaccessible Resource was named

Is that just assumed to be the repository, or if the error's on write, maybe it was worth logging what was refused? It's kinda frustrating to see "something was refused" with no real way to find out what :(

chickenandpork commented 5 months ago

Oh, wait, my failure already had permissions: check my copy of config above:

      ...
      # Note: Advice from https://github.com/pascalgn/automerge-action/issues/214
      contents: write
      ...

So this workaround from #214 was already in place? Or was it incorrectly in place ? Otherwise, the thing that's there in the problem example can't fix the problem.

pascalgn commented 5 months ago

I think it's not clear from the logging, but the error message comes directly from GitHub. If you search for "Resource not accessible by integration" you find lots of other people who are having various problems when calling the GitHub API. I agree that the error message is not helpful.

speedenator commented 2 months ago

I'm getting the same problem... using the above fairly vanilla workflow. Did anyone get this to work?

I'm on the free account so trying to use this to auto-merge after tests have been run, as that appears to be a feature reserved for paying customers ;). Don't know if that's material or not.

speedenator commented 2 months ago

random note: while I haven't gotten the above to work, I did get the following to work using my own personal GH token, not the default one. So perhaps a permission problem. permissions: contents: write env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} GH_TOKEN: ${{ secrets.MY_GH_TOKEN }} step: ...

YMMV. Thanks!