Skip to content

Commit 64c22b3

Browse files
committed
CI: PrAssignee.yml: .catch() and return the error object if 404 is encountered when checking collaborator status
1 parent 1735d8f commit 64c22b3

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

.github/workflows/PrAssignee.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ jobs:
3838
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
3939
with:
4040
retries: 5 # retry GitHub API requests up to 5 times, with exponential backoff
41-
retry-exempt-status-codes: 403
41+
retry-exempt-status-codes: "403,404"
42+
# In the above list:
43+
#
44+
# - 404 is in the list because we will always hit a 404 when the PR author is not
45+
# a committer. This 404 is normal and expected.
4246
script: |
4347
const oldPrAssignees = context.payload.pull_request.assignees
4448
.map(obj => obj.login)
@@ -55,7 +59,26 @@ jobs:
5559
headers: {
5660
'X-GitHub-Api-Version': '2022-11-28'
5761
}
58-
})
62+
}).catch((error) => {
63+
// So, I'm not sure if the error is being thrown by `@octokit/request.js` or
64+
// `@octokit/plugin-retry.js`. I suspect that the initial error is thrown by
65+
// `request.js`, and is subsequently propagated by `plugin-retry.js`.
66+
//
67+
// Anyway, the docs for `request.js` say the following:
68+
//
69+
// > If an error occurs, the promise is rejected with an `error` object
70+
//> containing 3 keys to help with debugging:
71+
// >
72+
// > - `error.status` The http response status code
73+
// > - `error.request` The request options such as `method`, `url` and `data`
74+
// > - `error.response` The http response object with `url`, `headers`, and `data`
75+
//
76+
// Source: https://github.com/octokit/request.js/blob/main/README.md#request
77+
//
78+
// So, inside this `.catch()`, we simply return that `error` object.
79+
80+
return error;
81+
});
5982
if (isCollaboratorResponseObj.status == 204) {
6083
var isCollaborator = true;
6184
} else if (isCollaboratorResponseObj.status == 404) {

0 commit comments

Comments
 (0)