sponsors-maintainers-man-completions: various fixes.

- fix name
- use correct command
This commit is contained in:
Mike McQuaid 2022-09-08 12:19:12 +01:00
parent 04dfb9d4b8
commit 344d47accc
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
3 changed files with 15 additions and 9 deletions

View File

@ -45,7 +45,7 @@ jobs:
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems- restore-keys: ${{ runner.os }}-rubygems-
- name: Update maintainers, manpage and completions - name: Update sponsors, maintainers, manpage and completions
id: update id: update
run: | run: |
git fetch origin git fetch origin
@ -69,7 +69,7 @@ jobs:
git checkout --no-track -B "${BRANCH}" origin/master git checkout --no-track -B "${BRANCH}" origin/master
fi fi
if brew sponsors if brew update-sponsors
then then
git add "${GITHUB_WORKSPACE}/README.md" git add "${GITHUB_WORKSPACE}/README.md"
git commit -m "Update sponsors." \ git commit -m "Update sponsors." \
@ -109,7 +109,7 @@ jobs:
fi fi
env: env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }} GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_BREW_UPDATE_MAINTAINERS_TOKEN }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_BREW_UPDATE_SPONSORS_MAINTAINERS_TOKEN }}
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }} HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
- name: Push commits - name: Push commits

View File

@ -40,9 +40,10 @@ module Homebrew
named_sponsors = [] named_sponsors = []
logo_sponsors = [] logo_sponsors = []
largest_monthly_amount = 0
GitHub.sponsorships("Homebrew").each do |s| GitHub.sponsorships("Homebrew").each do |s|
largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].compact.max largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max
named_sponsors << "[#{sponsor_name(s)}](#{sponsor_url(s)})" if largest_monthly_amount >= NAMED_MONTHLY_AMOUNT named_sponsors << "[#{sponsor_name(s)}](#{sponsor_url(s)})" if largest_monthly_amount >= NAMED_MONTHLY_AMOUNT
next if largest_monthly_amount < URL_MONTHLY_AMOUNT next if largest_monthly_amount < URL_MONTHLY_AMOUNT
@ -50,6 +51,8 @@ module Homebrew
logo_sponsors << "[![#{sponsor_name(s)}](#{sponsor_logo(s)})](#{sponsor_url(s)})" logo_sponsors << "[![#{sponsor_name(s)}](#{sponsor_logo(s)})](#{sponsor_url(s)})"
end end
odie "No sponsorships amounts found! Ensure you have sufficient permissions!" if largest_monthly_amount.zero?
named_sponsors << "many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew)" named_sponsors << "many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew)"
readme = HOMEBREW_REPOSITORY/"README.md" readme = HOMEBREW_REPOSITORY/"README.md"

View File

@ -444,7 +444,9 @@ module GitHub
current_sponsorships = result["data"]["organization"]["sponsorshipsAsMaintainer"] current_sponsorships = result["data"]["organization"]["sponsorshipsAsMaintainer"]
# The organisations mentioned above will show up as nil nodes. # The organisations mentioned above will show up as nil nodes.
sponsorships += current_sponsorships["nodes"].compact if (nodes = current_sponsorships["nodes"].compact.presence)
sponsorships += nodes
end
if (page_info = current_sponsorships["pageInfo"].presence) && if (page_info = current_sponsorships["pageInfo"].presence) &&
page_info["hasNextPage"].presence page_info["hasNextPage"].presence
@ -460,16 +462,17 @@ module GitHub
end end
sponsorships.map do |sponsorship| sponsorships.map do |sponsorship|
closest_tier_monthly_amount = sponsorship["tier"].fetch("closestLesserValueTier", nil)
&.fetch("monthlyPriceInDollars", nil)
monthly_amount = sponsorship["tier"]["monthlyPriceInDollars"]
sponsor = sponsorship["sponsorEntity"] sponsor = sponsorship["sponsorEntity"]
tier = sponsorship["tier"].presence || {}
monthly_amount = tier["monthlyPriceInDollars"].presence || 0
closest_tier = tier["closestLesserValueTier"].presence || {}
closest_tier_monthly_amount = closest_tier["monthlyPriceInDollars"].presence || 0
{ {
name: sponsor["name"].presence || sponsor["login"], name: sponsor["name"].presence || sponsor["login"],
login: sponsor["login"], login: sponsor["login"],
monthly_amount: monthly_amount, monthly_amount: monthly_amount,
closest_tier_monthly_amount: closest_tier_monthly_amount || 0, closest_tier_monthly_amount: closest_tier_monthly_amount,
} }
end end
end end