-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
_sponsors.sh
executable file
·86 lines (77 loc) · 2.16 KB
/
_sponsors.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
set -eu -o pipefail
shopt -s lastpipe inherit_errexit
function o { printf -->&2 "%s:%s\\n" "${0##*/}" "$(printf " %q" "$@")"; "$@"; }
function gh-org-sponsors-monthly-tiers {
# shellcheck disable=SC2016
gh api graphql --paginate -F org="${1:?org}" -f query='
query Tiers($endCursor: String, $org: String!) {
organization(login: $org) {
... on Sponsorable {
sponsorsListing {
tiers(first: 100, after: $endCursor) {
nodes {
id
name
description
isOneTime
monthlyPriceInDollars
}
pageInfo { hasNextPage, endCursor }
}
}
}
}
}
' --jq '.data.organization.sponsorsListing.tiers.nodes[] | select(.isOneTime | not)'
}
function gh-org-sponsorships {
# shellcheck disable=SC2016
gh api graphql --paginate -F org="${1:?org}" -f query='
query Sponsors($endCursor: String, $org: String!) {
organization(login: $org) {
... on Sponsorable {
sponsorshipsAsMaintainer(first: 100, includePrivate: false, after: $endCursor) {
nodes {
sponsorEntity {
... on User { login, name, url, websiteUrl }
... on Organization { login, name, url, websiteUrl }
}
tier {
id
closestLesserValueTier { id }
}
}
pageInfo { hasNextPage, endCursor }
}
}
}
}
' --jq '.data.organization.sponsorshipsAsMaintainer.nodes[]'
}
function jq-tierids-since {
jq --arg since "${1:?since}" -s -r 'until(.[0].description | contains($since); del(.[0])) | .[].id'
}
function jq-filter-tier {
jq --arg tier "${1:?tier}" 'select(.tier.id == $tier or .tier.closestLesserValueTier.id == $tier)'
}
function jq-sort-by {
jq -s "sort_by(.${1:?key}) | .[]"
}
function named-sponsors {
public_sponsorships=$(
GITHUB_TOKEN="${ADMIN_GITHUB_TOKEN:?}" \
o gh-org-sponsorships "${1:?org}" \
| jq-sort-by sponsorEntity.login \
| jq -s ''
)
GITHUB_TOKEN="${ADMIN_GITHUB_TOKEN:?}" \
o gh-org-sponsors-monthly-tiers "${1:?org}" \
| jq-tierids-since XMonad.Layout.Named \
| tac \
| while read -r tier; do
<<<"$public_sponsorships" jq '.[]' | jq-filter-tier "$tier" | jq '.sponsorEntity'
done \
| jq -s ''
}
"$@"