@@ -29232,23 +29232,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
2923229232Object.defineProperty(exports, "__esModule", ({ value: true }));
2923329233const core = __importStar(__nccwpck_require__(9190));
2923429234const github = __importStar(__nccwpck_require__(2145));
29235- try {
29236- const allowedIds = core.getInput('whitelisted-github-ids');
29237- if (allowedIds === undefined || allowedIds === "") {
29238- throw new Error("Input 'whitelisted-github-ids' was empty.");
29239- }
29240- const allowedUserIds = allowedIds.split(',');
29241- const userId = github.context.actor;
29242- if (allowedUserIds.includes(userId)) {
29243- console.log(`User ${userId} is allowed to run this workflow.`);
29235+ async function run() {
29236+ try {
29237+ const allowedIds = core.getInput('whitelisted-github-ids');
29238+ if (allowedIds === undefined || allowedIds === "") {
29239+ throw new Error("Input 'whitelisted-github-ids' was empty.");
29240+ }
29241+ const allowedUserIds = allowedIds.split(',');
29242+ const octokit = github.getOctokit(core.getInput('token'));
29243+ const username = github.context.actor;
29244+ const { data: user } = await octokit.rest.users.getByUsername({
29245+ username: username,
29246+ });
29247+ const userId = user.id.toString();
29248+ if (allowedUserIds.includes(userId)) {
29249+ console.log(`User ${userId} is allowed to run this workflow.`);
29250+ }
29251+ else {
29252+ throw new Error(`User ${userId} is not authorized to run this workflow.`);
29253+ }
2924429254 }
29245- else {
29246- throw new Error(`User ${userId} is not authorized to run this workflow.` );
29255+ catch (error) {
29256+ core.setFailed(error.message );
2924729257 }
2924829258}
29249- catch (error) {
29250- core.setFailed(error.message);
29251- }
29259+ run();
2925229260
2925329261
2925429262/***/ }),
0 commit comments