Skip to content

About

Show the pull requests you got merged into other people's projects: an SVG card + markdown for your GitHub profile README. CLI and GitHub Action, zero dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

upstream-card

Show the pull requests you got merged into other people's projects. upstream-card builds an SVG card and a markdown list of your merged PRs in other people's public repositories, for your GitHub profile README. It runs as a GitHub Action or a CLI and has zero dependencies.

upstream-card example: 14 PRs merged into 6 other projects

Most profile stat cards count everything: your own repos, forks, commits to scratch projects. Maintainers and hiring managers mostly want to know something else: did other projects accept your work? upstream-card counts only that. It shows PRs that were merged, into public repositories you don't own, grouped by project with stars and language.

Use it in your profile README (GitHub Action)

Add the card to your profile README (the <username>/<username> repo):

![My upstream contributions](upstream-card.svg)

Then add .github/workflows/upstream-card.yml:

name: upstream-card
on:
  schedule: [{ cron: "17 6 * * 1" }]   # weekly, Mondays 06:17 UTC; a card rarely needs fresher
  workflow_dispatch:                    # and a "Run workflow" button for a refresh right now
permissions:
  contents: write   # only to commit the refreshed card
jobs:
  card:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: JROtto5/upstream-card@284a5f5e74ebacdb6b5d57e95325559f0f920eaf # v0.2.1
        with:
          theme: auto            # follows the viewer's light/dark setting; or dark / light
          top: 6                 # projects on the card
          # exclude: my-employer,someone/fork   # owners or owner/repo to leave out
          # min-stars: 50        # only projects with at least this many stars
          # since: 2026-01-01    # only PRs merged on or after this date (UTC)
          # types: merged,reviewed   # also count PRs you reviewed
          # readme: README.md    # also write the full list between the markers below
      - run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add -A
          git diff --cached --quiet || { git commit -m "upstream-card: refresh" && git push; }

The workflow runs weekly by default: most profiles gain a merged PR every few weeks, not every hour, and a weekly run keeps your Actions minutes and GitHub's API budget for other things. Use the Run workflow button (Actions tab, upstream-card) to refresh right away after a merge, or change the cron line. The same file is in examples/upstream-card.yml.

upstream-card only rewrites a file when its content changed. A new merge changes it, and so does a change in a shown star count (exact below 1,000, in steps of 100 above). Add --no-stars (the Action's no-stars: true) if you want commits only when something merges. Pin the action to a commit SHA, as above, so a later change to this repository can't change what runs in yours.

With readme: README.md, the full markdown list (every project, with its latest PRs, links and dates) goes between these two markers in your README. If neither marker is there yet, both are added at the end of the file. A lone marker, or two in the wrong order, is an error, so nothing gets written in the wrong place:

<!-- upstream-card:start -->
<!-- upstream-card:end -->

Use it from the command line

Node 20 or newer, no install step. A token is required, because GitHub's GraphQL API has no anonymous access; only public data is read:

git clone https://github.com/JROtto5/upstream-card && cd upstream-card
GITHUB_TOKEN=$(gh auth token) node bin/upstream-card.js --user <login> --svg card.svg --md upstream.md
Option What it does
--user <login> The GitHub user to summarize (not needed with --from-json)
--svg <file> Where to write the card (default upstream-card.svg)
--theme auto|dark|light Card theme; auto (the default) follows the viewer's light/dark setting
--title <text> Card heading (default: <user>'s upstream contributions)
--top <n> Projects on the card (default 6); the markdown list always has all of them
--exclude <list> Comma-separated owners or owner/repo to leave out (--exclude-orgs is the same)
--min-stars <n> Leave out projects with fewer stars
--exclude-forks Leave out projects that are themselves forks
--since <YYYY-MM-DD> Only PRs merged on or after this date (UTC)
--types <list> What to count: merged (the default), reviewed, or merged,reviewed
--md <file> Also write the markdown list
--readme <file> Put the markdown list between the upstream-card markers in this file
--json <file> / --from-json <file> Save the summary, or render from a saved one offline; the filters still apply
--no-stars Leave star counts off the card and the list
--cache <file> Remember what GitHub showed last time in this file; a run where nothing changed skips the full fetch (see below)
--dry-run Print which files would be created or updated, and write nothing

Skipping runs when nothing changed (--cache)

With --cache <file> (the Action's cache:) a run first asks GitHub one small question per type: how many PRs the search finds, and which one was updated last. If the answer is the same as last time, the run ends there: no full fetch, no file touched. A full run is 2 or more GraphQL calls per type (more for long histories, which are read in date windows and pages of 100), so the saving grows with your history; for a short one it is about one call. GitHub's search API sends no ETag, so this is a plain comparison, not a conditional request, and the check itself counts against the rate limit like any small query.

Any new merge or review, a PR that disappears (deleted repo, repo made private) or an edited title changes the answer and gives a full run, which then saves the new state. A full run is also forced when the options changed (a different --top must redraw the card), when an output file is missing, when the cache is older than 30 days, and when the check itself fails. If the check is rate limited, the run keeps your last card, as described under Rate limits.

The cache file changes whenever the state does, so keep it out of your commits and persist it with actions/cache:

      - uses: actions/cache@v4   # or pin it to a SHA, like the action below
        with:
          path: .upstream-card-cache.json
          key: upstream-card-${{ github.run_id }}
          restore-keys: upstream-card-
      - uses: JROtto5/upstream-card@284a5f5e74ebacdb6b5d57e95325559f0f920eaf
        with:
          cache: .upstream-card-cache.json

The trade-off: a star count or a repo rename shows up only on the next full run (at most 30 days away), and the git add -A in the example workflow would commit the cache file, so add it to .gitignore there. It isn't needed with the default weekly schedule; it's for runs more often than that.

What counts

  • Merged pull requests only, by default. Closed and open ones don't count (with --types reviewed, see below, PRs you reviewed count in any state).
  • Public repositories only. The search always adds is:public, and every result's repository is checked again (isPrivate), so private work, such as an employer's or a client's repos, never reaches a public card, even when your token can see it. Deleted repositories are skipped.
  • Renamed or transferred projects show under their current name, and PRs from before and after a rename count as one project.
  • Not your own repositories. The search drops repos you own (-user:<you>). Use --exclude for organizations you belong to or forks you'd rather leave out.
  • First contributions are marked in the markdown list (🌱 first contribution on the PR that was your first merge in that project; when it isn't one of the PRs shown, the "and N more" line names its date). Reviewed PRs are never marked. With --since there are no marks, since the oldest PR in the slice isn't known to be your first. The card is unchanged.
  • Reviewed PRs are opt-in (--types reviewed or merged,reviewed; the Action's types:). They are PRs someone else wrote, in public repositories you don't own, that you reviewed (any state; GitHub's reviewed-by: search). With both types, the card's bar still counts merged PRs, a project you only reviewed in shows "N reviewed" in place of a bar, and the totals line gives both numbers. Search has no review date, so --since and the dates in the list use the day the PR was opened, which also keeps the output from changing when a PR you reviewed later gets new comments. A saved --json summary holds only the types it was made with: save it with --types merged,reviewed to filter later with --from-json.
  • Projects are ranked by merged PRs, then by reviewed PRs, then by stars, then by the most recent PR.
  • GitHub's search returns at most 1,000 results per query. Past that, upstream-card splits the date range into windows that each fit, so long histories are counted in full. Two limits remain, and both print a warning rather than cutting silently: a single day with more than 1,000 merged PRs, and the library's max option (5,000 by default), which keeps the newest PRs. Both apply to merged and reviewed PRs separately; reviewed PRs are windowed by the day they were opened.

Rate limits

If GitHub's API budget runs out mid-run (the primary limit, or the secondary "slow down" one), upstream-card writes nothing: your last card, list and README block stay exactly as they were, it prints a notice (a warning annotation inside Actions) and exits 0, so a scheduled run doesn't go red for a limit that resets on its own. Nothing is written until every page has been read, so a half-built card is never saved. If a file it would have written doesn't exist yet there is nothing to keep, so that case exits 1. A bad token and other API errors still fail the run.

Library

import { fetchPRs, summarize, renderSVG, renderMarkdown } from 'upstream-card';

const prs = await fetchPRs('octocat', { token, types: ['merged', 'reviewed'] }); // fetchMergedPRs(user, opts) is merged only
const summary = summarize(prs, { top: 6, minStars: 10, types: ['merged', 'reviewed'] });
const svg = renderSVG(summary, { user: 'octocat', theme: 'light' });

types is an array of 'merged' and/or 'reviewed'; fetchPRs, probe and summarize throw a TypeError for anything else, and a repeated type counts once.

When GitHub's API budget runs out, fetchPRs throws a RateLimitError (also exported) whose resetAt is a Date, or null when GitHub didn't say, so a caller can keep its last result.

Development

npm test   # node --test, no dependencies; uses xmllint when it's installed
UPDATE_SNAPSHOTS=1 npm test   # after an intended change to the card's look

The tests cover the npm bin symlink, pagination past 100 results and date-window splitting past 1,000; private, deleted and renamed repositories; hostile repository names and titles (escaped, checked with xmllint); a second run changing nothing; a missing token; --since boundaries; rate limits (the last card is kept, byte for byte); the --cache check (nothing changed means one call per type and no writes), and snapshots of all three themes.

The code was reviewed with crucible, an evidence-first AI code reviewer, before each release.

License

MIT

About

Show the pull requests you got merged into other people's projects: an SVG card + markdown for your GitHub profile README. CLI and GitHub Action, zero dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages