Merge pull request #126 from github/actions-bot-user-fixes
properly fetch "login" when using Actions tokens instead of a PAT
This commit is contained in:
Коммит
365f527f8a
|
@ -37665,9 +37665,32 @@ class GitHubProvider {
|
|||
}
|
||||
|
||||
async getCurrentUser() {
|
||||
const { data: currentUser } =
|
||||
await this.octokit.rest.users.getAuthenticated();
|
||||
return currentUser.login;
|
||||
let login;
|
||||
try {
|
||||
core.debug(
|
||||
`attempting to get current user via octokit.rest.users.getAuthenticated()`,
|
||||
);
|
||||
const { data: currentUser } =
|
||||
await this.octokit.rest.users.getAuthenticated();
|
||||
login = currentUser.login;
|
||||
core.debug(
|
||||
"obtained current user via octokit.rest.users.getAuthenticated()",
|
||||
);
|
||||
} catch (error) {
|
||||
core.debug(error);
|
||||
core.debug(
|
||||
`octokit.rest.users.getAuthenticated() failed, trying with octokit.rest.apps.getAuthenticated() instead`,
|
||||
);
|
||||
const { data: currentApp } =
|
||||
await this.octokit.rest.apps.getAuthenticated();
|
||||
login = currentApp.slug;
|
||||
core.debug(
|
||||
"obtained current user via octokit.rest.apps.getAuthenticated()",
|
||||
);
|
||||
}
|
||||
|
||||
core.debug(`current user: ${login}`);
|
||||
return login;
|
||||
}
|
||||
|
||||
// check if the current authenticated user (login) has an active APPROVED review on the PR
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -11,9 +11,32 @@ class GitHubProvider {
|
|||
}
|
||||
|
||||
async getCurrentUser() {
|
||||
const { data: currentUser } =
|
||||
await this.octokit.rest.users.getAuthenticated();
|
||||
return currentUser.login;
|
||||
let login;
|
||||
try {
|
||||
core.debug(
|
||||
`attempting to get current user via octokit.rest.users.getAuthenticated()`,
|
||||
);
|
||||
const { data: currentUser } =
|
||||
await this.octokit.rest.users.getAuthenticated();
|
||||
login = currentUser.login;
|
||||
core.debug(
|
||||
"obtained current user via octokit.rest.users.getAuthenticated()",
|
||||
);
|
||||
} catch (error) {
|
||||
core.debug(error);
|
||||
core.debug(
|
||||
`octokit.rest.users.getAuthenticated() failed, trying with octokit.rest.apps.getAuthenticated() instead`,
|
||||
);
|
||||
const { data: currentApp } =
|
||||
await this.octokit.rest.apps.getAuthenticated();
|
||||
login = currentApp.slug;
|
||||
core.debug(
|
||||
"obtained current user via octokit.rest.apps.getAuthenticated()",
|
||||
);
|
||||
}
|
||||
|
||||
core.debug(`current user: ${login}`);
|
||||
return login;
|
||||
}
|
||||
|
||||
// check if the current authenticated user (login) has an active APPROVED review on the PR
|
||||
|
|
Загрузка…
Ссылка в новой задаче