Update Sponsors #3339
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Sponsors | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 * * * *' # every hour (UTC) | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - login: kmendell | |
| token_secret: SPONSORKIT_GITHUB_TOKEN_KMENDELL | |
| - login: stonith404 | |
| token_secret: SPONSORKIT_GITHUB_TOKEN_STONITH404 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: pnpm/action-setup@v4 | |
| - name: Set node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - run: pnpm install | |
| - name: Update sponsors (${{ matrix.login }}) | |
| run: pnpm build | |
| env: | |
| SPONSORKIT_GITHUB_TOKEN: ${{ secrets[matrix.token_secret] }} | |
| SPONSORKIT_GITHUB_LOGIN: ${{ matrix.login }} | |
| - name: Upload sponsors JSON (${{ matrix.login }}) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sponsors-${{ matrix.login }} | |
| path: sponsors.${{ matrix.login }}.json | |
| if-no-files-found: error | |
| merge: | |
| runs-on: ubuntu-latest | |
| needs: generate | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Download kmendell sponsors | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: sponsors-kmendell | |
| path: artifacts/kmendell | |
| - name: Download stonith404 sponsors | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: sponsors-stonith404 | |
| path: artifacts/stonith404 | |
| - name: Set node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: Merge JSON | |
| shell: bash | |
| run: | | |
| node <<'NODE' | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const read = (p) => JSON.parse(fs.readFileSync(p, 'utf8')); | |
| const a = read(path.join('artifacts', 'kmendell', 'sponsors.kmendell.json')); | |
| const b = read(path.join('artifacts', 'stonith404', 'sponsors.stonith404.json')); | |
| const byLogin = new Map(); | |
| for (const item of [...a, ...b]) { | |
| const key = item.login || item.name; | |
| if (!byLogin.has(key)) { | |
| byLogin.set(key, { ...item }); | |
| } else { | |
| const existing = byLogin.get(key); | |
| // Sum amounts across accounts | |
| existing.amount = (existing.amount || 0) + (item.amount || 0); | |
| // Prefer existing values, but fill gaps | |
| if (!existing.link && item.link) existing.link = item.link; | |
| if (item.org) existing.org = true; | |
| if (!existing.avatar && item.avatar) existing.avatar = item.avatar; | |
| if (!existing.name && item.name) existing.name = item.name; | |
| } | |
| } | |
| const merged = Array.from(byLogin.values()).sort((x, y) => y.amount - x.amount); | |
| fs.writeFileSync('sponsors.json', JSON.stringify(merged, null, 2)); | |
| NODE | |
| - name: Commit merged sponsors.json | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| author_name: GitHub Actions | |
| author_email: 41898282+github-actions[bot]@users.noreply.github.com | |
| message: 'chore: update sponsors [skip ci]' | |
| add: 'sponsors.json' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |