-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Expand file tree
/
Copy pathget-current-user.mjs
More file actions
41 lines (37 loc) · 1.4 KB
/
get-current-user.mjs
File metadata and controls
41 lines (37 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import github from "../../github.app.mjs";
const DEFAULT_ORGS_LIMIT = 20;
const DEFAULT_TEAMS_LIMIT = 20;
export default {
key: "github-get-current-user",
name: "Get Current User",
description: "Gather a full snapshot of the authenticated GitHub actor, combining `/user`, `/user/orgs`, and `/user/teams`. Returns profile metadata (login, name, email, company, plan, creation timestamps) and trimmed lists of organizations and teams for quick role awareness. Helpful when you need to validate which user is calling the API, adapt behavior based on their org/team memberships, or provide LLMs with grounding before repository operations. [See the documentation](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user).",
version: "0.0.3",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
github,
},
async run({ $ }) {
const [
user,
organizations,
teams,
] = await Promise.all([
this.github.getAuthenticatedUser(),
this.github.getOrganizations()
.then((orgs) => orgs.slice(0, DEFAULT_ORGS_LIMIT)),
this.github.getTeams()
.then((teamsResponse) => teamsResponse.slice(0, DEFAULT_TEAMS_LIMIT)),
]);
$.export("$summary", `Retrieved GitHub user ${user.login}`);
return {
user,
organizations,
teams,
};
},
};