You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Idea is that when the module is loaded in either a workflow or a function app (triggering on a webhook) it should be able to collect some info about the event, type of action etc.
Payload fields:
Action
Event type (when webhook, header X-GITHUB-EVENT, when action, env:GITHUB_EVENT)
Think an addition to this would be to get info like "who am I" as in a hierarchy. What enterprise, organization, repo triggered this.
Enterprise
Organization
Repository
For context aware, it might also want to get the "installation" piece of the event. Not sure when these are in the payload of the event however.
$context=Get-GitHubContext# GraphQL Endpoint$GraphQLEndpoint='https://api.github.com/graphql'# Headers$Headers=@{
'Content-Type'='application/json'
}
# GraphQL Query for fetching user's organizations and repositories$Query=@'{ viewer { enterprises(first: 100) { nodes { name slug id } } organizations(first: 100) { nodes { name login url } } repositories(first: 100, privacy: PUBLIC) { nodes { name url isPrivate } } }}'@# Prepare the body for the HTTP POST$Body=@{
query=$Query
} |ConvertTo-Json-Depth 10# Make the HTTP POST request$response=Invoke-RestMethod-Uri $GraphQLEndpoint-Headers $Headers-Method Post -Body $Body-Token $context.Token-Authentication Bearer
# Process the responseif ($response) {
Write-Output"User Login: $($response.data.viewer.login)"Write-Output'Enterprises:'$response.data.viewer.enterprises.nodes|ForEach-Object {
Write-Output" - Name: $($_.name), Slug: $($_.slug), ID: $($_.id)"
}
Write-Output'Organizations:'$response.data.viewer.organizations.nodes|ForEach-Object {
Write-Output" - Name: $($_.name), Login: $($_.login), URL: $($_.url)"if ($_.enterprise-ne$null) {
Write-Output" Enterprise: $($_.enterprise.name), URL: $($_.enterprise.url)"
}
}
Write-Output'Repositories:'$response.data.viewer.repositories.nodes|ForEach-Object {
Write-Output" - Name: $($_.name), URL: $($_.url), Private: $($_.isPrivate)"
}
} else {
Write-Error'Failed to fetch data from GitHub API.'
}
MariusStorhaug
changed the title
🚀[Feature]: Add context aware code, so that it automatically populates certain variables about the running environment
🚀[Feature]: Add context aware code for GitHub Actions, so that it automatically populates certain variables about the running environment
Dec 5, 2024
Idea is that when the module is loaded in either a workflow or a function app (triggering on a webhook) it should be able to collect some info about the event, type of action etc.
Payload fields:
Think an addition to this would be to get info like "who am I" as in a hierarchy. What enterprise, organization, repo triggered this.
For context aware, it might also want to get the "installation" piece of the event. Not sure when these are in the payload of the event however.
Similar to the contexts that you can see made available here:
https://github.com/actions/github-script/tree/v7/
The text was updated successfully, but these errors were encountered: