Skip to content

"HttpError: Resource not accessible by integration" if default Actions permissions are used #1

Open

Description

@Calinou

I've tried to use version 3.1.0 of this action, but I get the following error:

Error: HttpError: Resource not accessible by integration
Error: Resource not accessible by integration

Full log:

Run garrettjoecox/[email protected]
  with:
    repo-token: ***
    pr-number: 2
    section-name: artifacts
    section-value: ### Build artifacts
    - [android-template.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067957.zip)
    - [ios-template.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067958.zip)
    - [linux-editor-mono.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067959.zip)
    - [linux-template-minimal.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067960.zip)
    - [linux-template-mono.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067961.zip)
    - [macos-editor.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067963.zip)
    - [macos-template.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067964.zip)
    - [web-template.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067965.zip)
    - [windows-editor.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067966.zip)
    - [windows-template.zip](https://nightly.link/Calinou/godot-ci-temp-test/actions/artifacts/682067967.zip)
Error: HttpError: Resource not accessible by integration
Error: Resource not accessible by integration

CI run link: https://github.com/Calinou/godot-ci-temp-test/actions/runs/4895925195/jobs/8742093347

Workflow file:

name: Link PR artifacts pr_artifacts.yml
on:
  workflow_run:
    workflows:
      - 🔗 GHA
    types:
      - completed

jobs:
  pr-artifacts:
    runs-on: ubuntu-22.04
    if: ${{ github.event.workflow_run.event == 'pull_request' }}
    steps:
      - id: pr-number
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script: |
            const {owner, repo} = context.repo;
            const pullHeadSHA = '${{github.event.workflow_run.head_sha}}';
            const pullUserId = ${{github.event.sender.id}};
            const prNumber = await (async () => {
              const pulls = await github.rest.pulls.list({owner, repo});
              for await (const {data} of github.paginate.iterator(pulls)) {
                for (const pull of data) {
                  if (pull.head.sha === pullHeadSHA && pull.user.id === pullUserId) {
                    return pull.number;
                  }
                }
              }
            })();

            if (!prNumber) {
              return core.error(`No matching pull request found`);
            }

            return prNumber;

      - id: artifacts-text
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script: |
            let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
              owner: context.repo.owner,
              repo: context.repo.repo,
              run_id: context.payload.workflow_run.id,
            });

            return allArtifacts.data.artifacts.reduce((acc, item) => {
              if (item.name === "assets") return acc;
              acc += `
              - [${item.name}.zip](https://nightly.link/${context.repo.owner}/${context.repo.repo}/actions/artifacts/${item.id}.zip)`;
              return acc;
            }, '### Build artifacts');

      - id: add-to-pr
        uses: garrettjoecox/[email protected]
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'
          pr-number: ${{ steps.pr-number.outputs.result }}
          section-name: artifacts
          section-value: '${{ steps.artifacts-text.outputs.result }}'

Actions settings:

image

Do I need to enable Read and write permissions? If I use granular permissions in the YAML, is there a stricter set of permissions I can grant?

Edit: Setting permissions to Read and write permissions did the trick, but I wonder if more granular permissions could be used.

Activity

  1. changed the title [-]HttpError: Resource not accessible by integration[/-] [+]"HttpError: Resource not accessible by integration" if default Actions permissions are used[/+] on May 5, 2023
  2. AnYoung627 commented on Jan 27, 2025

    @AnYoung627

    The necessary granular permission is

    pull-requests: write
    

    So in your case:

    name: Link PR artifacts pr_artifacts.yml
    on:
      workflow_run:
        workflows:
          - 🔗 GHA
        types:
          - completed
    
    jobs:
      pr-artifacts:
        permissions:
          pull-requests: write
        runs-on: ubuntu-22.04
        if: ${{ github.event.workflow_run.event == 'pull_request' }}
        steps:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions