pr-compliance-action
pr-compliance-action copied to clipboard
Give a better error than "Resource not accessible by integration" when permissions lacking
Is your feature request related to a problem? Please describe.
When a repository's actions/job/workflow aren/isn't configured with enough permissions, mtfoley/pr-compliance-action
outputs very little information:
Error: This PR's title should conform to specification at https://conventionalcommits.org/
Error: Resource not accessible by integration
JoshuaKGoldberg/template-typescript-node-package/actions/runs/5032810384/jobs/9026669253?pr=456
Per https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues/457, it looks like it's not always possible for repositories to be configured properly right now. Specifically - forks of public repos are just... not able to give write token permissions to actions run in PRs? (please correct me if I'm wrong!)
Describe the solution you'd like
Either way, how about one or (my preference) both of:
- Saying what comment would be posted in the action's output before trying to post the comment
- Outputting a custom warning line expliaining why a comment wasn't posted in this known case?
Since we have almost no error handling other than one big try/catch block, I'd suggest a solution where each octokit call has its own error handling, so we can do more helpful suggestions. I've been writing in Golang primarily at work lately (handle ALL the errors), so I'm looking at this code like "who wrote this?".
Perhaps there's a different route where https://github.com/actions/core or similar offers a way to verify the workflow is getting the permissions it asked for :shrug:
EDIT: and yes @JoshuaKGoldberg we could totally add an action output that reflects the code comment the action would/does try to apply.
Golang
Yessssssss let's return all the Error
s!!
Golang
Yessssssss let's return all the
Error
s!!
I started a new PR for this one. I haven't tried it anywhere yet, but you're welcome to give it a try if there's a reproduction you already have going.