Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Resource not accessible by integration #276

Open
ssbarnea opened this issue Jan 5, 2023 · 6 comments
Open

Error: Resource not accessible by integration #276

ssbarnea opened this issue Jan 5, 2023 · 6 comments
Assignees

Comments

@ssbarnea
Copy link

ssbarnea commented Jan 5, 2023

I am getting Error: Resource not accessible by integration while using this action and I have no idea what is causing it.

Example: https://github.com/ansible-community/molecule/actions/runs/3842360113/jobs/6543589185

The body of of the action can be seen at https://github.com/ansible/devtools/blob/main/.github/workflows/ack.yml#L57-L61

The reason why this is in a different repository is because I use a reusable github action.

Before saying that this might not have the required access to editing the PR, take a look at previous action which is auto-approve-review, which runs successfully. So basically only this one is affected.

Any ideas about what can cause that?

@alexwilson
Copy link
Owner

Hey, I think this is caused by: https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ - and so the answer should be in #18. Can you confirm if you're using the default token, or injecting one into the workflow @ssbarnea?

@alexwilson alexwilson self-assigned this Jan 25, 2023
@lcarva
Copy link

lcarva commented Jan 30, 2023

I'm still hitting this with the following:

---
name: Enable auto-merge
"on":
  pull_request_target:
    types:
      - opened
      - reopened
    branches:
      - main
jobs:
  enable-auto-merge:
    runs-on: ubuntu-latest
    if: github.event.pull_request.user.login == 'my-super-duper-bot'
    steps:
      - uses: alexwilson/enable-github-automerge-action@main
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Presumably, this is because the workflow is getting triggered on opened and reopened which are not a "trusted event" like labeled?

If so, what's the workaround in this case? Maybe a personal access token is the only way forward.

@lcarva
Copy link

lcarva commented Jan 30, 2023

Actually, this seems to have worked after changing Settings > Actions > General > Workflow permissions from "read" to "read+write".

@alexwilson
Copy link
Owner

I think you've hit the nail on the head and that this is another change with Github's permissions, but can't substantiate that because there's no changelog: I'll update the documentation in the coming days (unless you would prefer to contribute something!)

@lcarva
Copy link

lcarva commented Jun 29, 2023

I'm hitting this again today and I think it's because I've updated my workflow and job to be explicit about which permissions it needs:

---
name: Enable auto-merge
"on":
  pull_request_target:
    types:
      - opened
      - reopened
    branches:
      - main

# This is new
permissions:
  pull-requests: read

jobs:
  enable-auto-merge:
    runs-on: ubuntu-latest
    if: github.event.pull_request.user.login == 'rh-tap-build-team[bot]'
    # This is also new
    permissions:
      pull-requests: write
    steps:
      - uses: alexwilson/enable-github-automerge-action@253948b2e2433d985bbbebe7887ca347e1e1b1ec # main
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Any idea what the full set of permissions are?

@lcarva
Copy link

lcarva commented Jun 29, 2023

After some trial and error, it looks like the action requires contents: write instead of pull-requests: write. I guess enabling automerge falls into this category.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants