Skip to content

Commit

Permalink
feat: multiple github sources
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Oct 9, 2024
1 parent a3c7569 commit 255e369
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/scheduler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ jobs:
- name: Update sponsors
run: pnpm exec sponsorkit --dir .
env:
SPONSORKIT_GITHUB_LOGIN: LittleSound
SPONSORKIT_GITHUB_TOKEN: ${{ secrets.SPONSORKIT_GITHUB_TOKEN }}
# SPONSORKIT_AFDIAN_USER_ID: ${{ secrets.SPONSORKIT_AFDIAN_USER_ID }}
# SPONSORKIT_AFDIAN_TOKEN: ${{ secrets.SPONSORKIT_AFDIAN_TOKEN }}
SPONSORKIT_GITHUB_TOKEN_LITTLESOUND: ${{ secrets.SPONSORKIT_GITHUB_TOKEN_LITTLESOUND }}
SPONSORKIT_GITHUB_TOKEN_NEKOMEOWWW: ${{ secrets.SPONSORKIT_GITHUB_TOKEN_NEKOMEOWWW }}

- name: Commit
uses: EndBug/add-and-commit@v9
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.DS_Store
*.json
!package.json
.env
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"private": true,
"type": "module",
"packageManager": "[email protected]",
"scripts": {
"dev": "rm -f .cache.json && sponsorkit --dir ."
},
"dependencies": {
"sponsorkit": "^0.15.5"
},
Expand Down
31 changes: 30 additions & 1 deletion sponsorkit.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
import { defineConfig, tierPresets } from 'sponsorkit'
import { defineConfig, tierPresets, fetchSponsors, Sponsorship } from 'sponsorkit'

export default defineConfig({
formats: ['svg', 'png', 'json'],
includePastSponsors: true,
afdian: {
exechangeRate: 6.8,
},

github: {
login: 'LittleSound',
token: process.env.SPONSORKIT_GITHUB_TOKEN_LITTLESOUND,
},

async onSponsorsAllFetched(sponsors) {
const res = await fetchSponsors({
github: {
login: 'nekomeowww',
token: process.env.SPONSORKIT_GITHUB_TOKEN_NEKOMEOWWW,
},
})

sponsors.push(...res)

const sponsorMap = new Map<string, Sponsorship>()
for (const sponsor of sponsors) {
const key = sponsor.sponsor.login || Math.random().toString()
const theSame = sponsorMap.get(key)
if (theSame) {
theSame.monthlyDollars += sponsor.monthlyDollars
} else {
sponsorMap.set(key, sponsor)
}
}
return Array.from(sponsorMap.values())
},

tiers: [
{
title: 'Past Sponsors',
Expand Down

0 comments on commit 255e369

Please sign in to comment.