Is your feature request related to a problem?
We can use the sponsorship information from github to show current sponsorship levels and help people understand where we're at.
Describe your solution
- Show goals
- Query github to get current sponsorships from there
- Add data from a static json that would show outside-github sponsorships.
- Show current vs needed on ddev.com, ddev.readthedocs.io
- Show the current level on daily message.
- Figure out how to thank people who are already sponsoring in the message of the day. This would require a token I guess.
- Provide the json information as a static file for others to consume.
We already have lots of this happening in https://github.com/ddev/ddev.com/blob/main/src/lib/api.ts, but have not bundled it in this way.
Alternately, A beginning query for this is sponsorships.sh:
sponsorships.sh
#!/bin/bash
set -eu -o pipefail
# GitHub API endpoint and token
GITHUB_TOKEN should be a classic github PAT with "read:org" and "read:user"
TOKEN="${GITHUB_TOKEN}" # Use GITHUB_TOKEN from the environment
ORG="${ORG_NAME}" # Use ORG_NAME from the environment
API_URL="https://api.github.com/graphql"
# Ensure required environment variables are set
if [ -z "${TOKEN:-}" ]; then
echo "Error: GITHUB_TOKEN is not set."
exit 1
fi
if [ -z "${ORG:-}" ]; then
echo "Error: ORG_NAME is not set."
exit 1
fi
# GraphQL Query
QUERY=$(cat <<EOF
{
"query": "query { organization(login: \\"$ORG\\") { sponsorshipsAsMaintainer(first: 100) { totalCount nodes { sponsorEntity { ... on User { name } ... on Organization { name } } tier { name monthlyPriceInCents } } } } }"
}
EOF
)
# Fetch data from GitHub API
RESPONSE=$(curl -s -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$QUERY" \
$API_URL)
# Check for errors in the API response
if [ $? -ne 0 ] || echo "$RESPONSE" | jq -e '.errors' >/dev/null 2>&1; then
echo "Error fetching data from GitHub API:"
echo "$RESPONSE" | jq '.errors'
exit 1
fi
# Parse data with jq
TOTAL_SPONSORS=$(echo "$RESPONSE" | jq '.data.organization.sponsorshipsAsMaintainer.totalCount')
TOTAL_MONTHLY=$(echo "$RESPONSE" | jq '[.data.organization.sponsorshipsAsMaintainer.nodes[].tier.monthlyPriceInCents] | add / 100')
SPONSORS_PER_TIER=$(echo "$RESPONSE" | jq -r '
.data.organization.sponsorshipsAsMaintainer.nodes |
group_by(.tier.name) |
map({(.[0].tier.name): length}) |
add
')
# Create JSON result
RESULT=$(jq -n \
--arg totalMonthly "$TOTAL_MONTHLY" \
--argjson totalSponsors "$TOTAL_SPONSORS" \
--argjson sponsorsPerTier "$SPONSORS_PER_TIER" \
'{
total_monthly_sponsorship: ($totalMonthly | tonumber),
total_sponsors: $totalSponsors,
sponsors_per_tier: $sponsorsPerTier
}'
)
# Output JSON to file
echo "$RESULT" > sponsorship_data.json
echo "Sponsorship data saved to 'sponsorship_data.json'"
The results look like this:
{
"total_monthly_sponsorship": 2598,
"total_sponsors": 61,
"sponsors_per_tier": {
"$1 a month": 5,
"$10 a month": 10,
"$100 a month": 4,
"$100 one time": 1,
"$2 a month": 2,
"$20 a month": 1,
"$20 one time": 2,
"$200 one time": 1,
"$25 a month": 12,
"$250 one time": 1,
"$5 a month": 17,
"$50 a month": 1,
"$500 a month": 1,
"$530 a month": 1,
"$6 a month": 1,
"$8 a month": 1
}
}
Is your feature request related to a problem?
We can use the sponsorship information from github to show current sponsorship levels and help people understand where we're at.
Describe your solution
We already have lots of this happening in https://github.com/ddev/ddev.com/blob/main/src/lib/api.ts, but have not bundled it in this way.
Alternately, A beginning query for this is
sponsorships.sh:sponsorships.sh
The results look like this:
{ "total_monthly_sponsorship": 2598, "total_sponsors": 61, "sponsors_per_tier": { "$1 a month": 5, "$10 a month": 10, "$100 a month": 4, "$100 one time": 1, "$2 a month": 2, "$20 a month": 1, "$20 one time": 2, "$200 one time": 1, "$25 a month": 12, "$250 one time": 1, "$5 a month": 17, "$50 a month": 1, "$500 a month": 1, "$530 a month": 1, "$6 a month": 1, "$8 a month": 1 } }