file-changes-action icon indicating copy to clipboard operation
file-changes-action copied to clipboard

Warn about necessary permission

Open peterbe opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

I encountered this error: Screen Shot 2021-12-08 at 1 31 06 PM

Cryptic! Turns out, the solution was this:

diff --git a/.github/workflows/link-check-all.yml b/.github/workflows/link-check-all.yml
index 510685a690a56..7c40cf65f5791 100644
--- a/.github/workflows/link-check-all.yml
+++ b/.github/workflows/link-check-all.yml
@@ -13,6 +13,8 @@ on:
 
 permissions:
   contents: read
+  # Needed for the 'trilom/file-changes-action' action
+  pull-requests: read
 
 jobs:
   build:

Describe the solution you'd like

It took me too long to figure that out. I'm still getting used to setting permissions on my workflows. Perhaps we can add this to the README or even possibly something like this:

  } catch (error) {
+  if (error.name === 'HttpError' && +error.status === 403) {
+    console.warn("Make sure your workflow as the 'pull-requests: read' permission.")
+}
    const eString = `There was an error getting change files for repo:${repo} owner:${owner} pr:${pullNumber}`
    let ePayload: string
    if (error.name === 'HttpError' && +error.status === 404)

Describe alternatives you've considered

n/a

Additional context

If it wasn't clear I'm suggesting any/either:

  • Add a troubleshooting section to the README
  • Wrap the HttpError and inject a possibly useful message about workflow permissions.

peterbe avatar Dec 08 '21 18:12 peterbe