Skip to content

Commit 9ca8690

Browse files
test
1 parent 19246a1 commit 9ca8690

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

.github/workflows/Action-Test.yml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,74 @@ jobs:
4040
uses: ./
4141
with:
4242
Script: |
43-
LogGroup 'Get-GitHubZen' {
44-
Get-GitHubZen
43+
$context = Get-GitHubContext
44+
45+
# GraphQL Endpoint
46+
$GraphQLEndpoint = 'https://api.github.com/graphql'
47+
48+
# Headers
49+
$Headers = @{
50+
'Content-Type' = 'application/json'
51+
}
52+
53+
# GraphQL Query for fetching user's organizations and repositories
54+
$Query = @'
55+
{
56+
viewer {
57+
enterprises(first: 100) {
58+
nodes {
59+
name
60+
slug
61+
id
62+
}
63+
}
64+
organizations(first: 100) {
65+
nodes {
66+
name
67+
login
68+
url
69+
}
70+
}
71+
repositories(first: 100, privacy: PUBLIC) {
72+
nodes {
73+
name
74+
url
75+
isPrivate
76+
}
77+
}
78+
}
79+
}
80+
'@
81+
82+
# Prepare the body for the HTTP POST
83+
$Body = @{
84+
query = $Query
85+
} | ConvertTo-Json -Depth 10
86+
87+
# Make the HTTP POST request
88+
$response = Invoke-RestMethod -Uri $GraphQLEndpoint -Headers $Headers -Method Post -Body $Body -Token $context.Token -Authentication Bearer
89+
90+
# Process the response
91+
if ($response) {
92+
Write-Output "User Login: $($response.data.viewer.login)"
93+
Write-Output 'Enterprises:'
94+
$response.data.viewer.enterprises.nodes | ForEach-Object {
95+
Write-Output " - Name: $($_.name), Slug: $($_.slug), ID: $($_.id)"
96+
}
97+
Write-Output 'Organizations:'
98+
$response.data.viewer.organizations.nodes | ForEach-Object {
99+
Write-Output " - Name: $($_.name), Login: $($_.login), URL: $($_.url)"
100+
if ($_.enterprise -ne $null) {
101+
Write-Output " Enterprise: $($_.enterprise.name), URL: $($_.enterprise.url)"
102+
}
103+
}
104+
105+
Write-Output 'Repositories:'
106+
$response.data.viewer.repositories.nodes | ForEach-Object {
107+
Write-Output " - Name: $($_.name), URL: $($_.url), Private: $($_.isPrivate)"
108+
}
109+
} else {
110+
Write-Error 'Failed to fetch data from GitHub API.'
45111
}
46112
47113
ActionTestCommands:

0 commit comments

Comments
 (0)