Skip to content

Commit

Permalink
Avoid full org render by default
Browse files Browse the repository at this point in the history
This might not be what we want by default, so leave it as an optional troubleshooting aid.
  • Loading branch information
kzu committed Aug 12, 2022
1 parent b2d54e0 commit a2e84e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
token:
description: The token to use for querying the GitHub API for sponsorship information. Typically set to secrets.GH_TOKEN.
required: true
verbose:
description: Whether to perform verbose logging when failing to find a sponsorship. Defaults to false.
required: false
default: false

branding:
icon: heart
Expand All @@ -44,5 +48,6 @@ runs:
SPONSOR_SENDER_LOGIN: ${{ github.event.sender.login }}
SPONSOR_SENDER_ID: ${{ github.event.sender.node_id }}
SPONSOR_ISSUE: ${{ github.event.issue.number || github.event.pull_request.number }}
SPONSOR_VERBOSE: ${{ inputs.verbose }}
GH_TOKEN: ${{ inputs.token }}
run: sponsor-labeler.ps1
32 changes: 18 additions & 14 deletions sponsor-labeler.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$verbose = [bool]::Parse($env:SPONSOR_VERBOSE ?? "false")

$query = gh api graphql --paginate -f owner=$env:SPONSORABLE -f query='
query($owner: String!, $endCursor: String) {
organization (login: $owner) {
Expand Down Expand Up @@ -85,20 +87,22 @@ query ($user: String!, $endCursor: String) {
}

if ($null -eq $amount) {
Write-Output "User $env:SPONSOR_SENDER_LOGIN is not a sponsor of $env:SPONSORABLE and none of their organizations are:"
$user |
ConvertFrom-Json |
select @{ Name='nodes'; Expression={$_.data.user.organizations.nodes}} |
select -ExpandProperty nodes
format-table

Write-Output "`n$env:SPONSORABLE sponsoring organizations:"
$orgs |
ConvertFrom-Json |
select @{ Name='nodes'; Expression={$_.data.organization.sponsorshipsAsMaintainer.nodes}} |
select -ExpandProperty nodes |
select -ExpandProperty sponsorEntity |
format-table
Write-Output "User $env:SPONSOR_SENDER_LOGIN is not a sponsor of $env:SPONSORABLE and none of their organizations are."
if ($verbose) {
$user |
ConvertFrom-Json |
select @{ Name='nodes'; Expression={$_.data.user.organizations.nodes}} |
select -ExpandProperty nodes
format-table

Write-Output "`n$env:SPONSORABLE sponsoring organizations:"
$orgs |
ConvertFrom-Json |
select @{ Name='nodes'; Expression={$_.data.organization.sponsorshipsAsMaintainer.nodes}} |
select -ExpandProperty nodes |
select -ExpandProperty sponsorEntity |
format-table
}

return
} else {
Expand Down

0 comments on commit a2e84e3

Please sign in to comment.