action icon indicating copy to clipboard operation
action copied to clipboard

Action Needs Permissions to Comment

Open griffin-ezbot opened this issue 1 year ago • 2 comments

Bug description

Using the recommended yml from the README.md:

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ] # ⬅ Add other branches you want size checks on

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14' # ⬅ Specify a version of Node.js to build your app

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

results in the following error when the action is triggered: Screenshot 2024-03-14 at 10 03 19 AM

Solution: add the following to your recommended yml

permissions:
  pull-requests: write

Reproduction steps

See above

Environment

  • pkg-size-action version: v1.1.1
  • Operating System: Local: MacOS 14.2.1, ubuntu-latest on the action itself
  • Node version: 20

griffin-ezbot avatar Mar 14 '24 15:03 griffin-ezbot

You can also grant "Read and write permissions" in your repository settings:

https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-default-github_token-permissions

Would you be open to submitting a PR to document this?

privatenumber avatar Mar 14 '24 16:03 privatenumber

FWIW, for this to work in a private repo with restrictive permissions on GITHUB_TOKEN (see last comment)

permissions:
  contents: read
  pull-requests: write

griffin-ezbot avatar Oct 26 '24 18:10 griffin-ezbot