-
Notifications
You must be signed in to change notification settings - Fork 2
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
Better errors #294
Merged
Merged
Better errors #294
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
46aac86
Better errors
Que3216 9a0f54f
Merge branch 'main' of github.com:alwaysmeticulous/report-diffs-actio…
Que3216 d488e6e
Fix
Que3216 7ccce62
Add actions write permission
Que3216 52f8705
Improvements
Que3216 a487d6c
Improvements to more errors
Que3216 e2005cd
More improvements
Que3216 bdfb624
Update src/utils/wait-for-deployment-url.ts
Que3216 5a6d83b
Use logger rather than console
Que3216 ce50df6
console -> logger
Que3216 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ on: | |
pull_request: {} | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
statuses: write | ||
pull-requests: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ on: | |
pull_request: {} | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
statuses: write | ||
pull-requests: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { DOCS_URL } from "./constants"; | ||
|
||
export const isGithubPermissionsError = ( | ||
error: MaybeOctokitRequestError | unknown | ||
): boolean => { | ||
const message = getErrorMessage(error); | ||
return ( | ||
message.toLowerCase().includes("resource not accessible by integration") || | ||
(error as MaybeOctokitRequestError)?.status === 403 | ||
); | ||
}; | ||
|
||
export const getErrorMessage = (error: unknown) => { | ||
const message = (error as MaybeOctokitRequestError)?.message ?? ""; | ||
return typeof message === "string" ? message : ""; | ||
}; | ||
|
||
// Octokit returns RequestErrors, which have a message and a code | ||
// But we can't make any strong assumptions, so we type it on the safe side | ||
// https://github.com/octokit/request-error.js/blob/372097e9b16f70d4ad75089003dc9154e304faa7/src/index.ts#L16 | ||
type MaybeOctokitRequestError = | ||
| { | ||
message?: string | unknown; | ||
status?: number | unknown; | ||
} | ||
| null | ||
| undefined; | ||
|
||
export const DEFAULT_FAILED_OCTOKIT_REQUEST_MESSAGE = `Please check www.githubstatus.com, and that you have setup the action correctly, including with the correct permissions: see ${DOCS_URL} for the correct setup.`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat duplicative with the logic in our monorepo (source). Is it worth moving to the sdk or too small?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think too small to be worth it