{"id":16633532,"url":"https://github.com/lukehagar/stats-action","last_synced_at":"2025-12-26T02:08:06.199Z","repository":{"id":224954326,"uuid":"763533795","full_name":"LukeHagar/stats-action","owner":"LukeHagar","description":"A github action to grab github stats for further processing","archived":false,"fork":false,"pushed_at":"2024-04-08T21:14:54.000Z","size":646,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-21T01:24:00.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukeHagar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-26T13:30:13.000Z","updated_at":"2024-03-02T17:14:40.000Z","dependencies_parsed_at":"2024-04-11T14:02:40.527Z","dependency_job_id":null,"html_url":"https://github.com/LukeHagar/stats-action","commit_stats":null,"previous_names":["lukehagar/stats"],"tags_count":4,"template":false,"template_full_name":"actions/javascript-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fstats-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fstats-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fstats-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeHagar%2Fstats-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeHagar","download_url":"https://codeload.github.com/LukeHagar/stats-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243125639,"owners_count":20240276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T05:23:57.606Z","updated_at":"2025-12-26T02:08:06.194Z","avatar_url":"https://github.com/LukeHagar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Stats Action\n\nA GitHub Action that collects comprehensive statistics for a user's GitHub profile and outputs them to a JSON file. Perfect for building profile READMEs, dashboards, or personal analytics.\n\n## Features\n\n- **Profile Data**: Name, bio, company, location, social links\n- **Contribution Stats**: Total contributions, streaks, most active day, monthly breakdown\n- **Repository Metrics**: Stars, forks, views, top repositories\n- **Code Statistics**: Lines added/deleted, commit counts, languages with percentages\n- **Social Stats**: Followers, following, stars given\n- **Activity Data**: Pull requests, issues, PR reviews, discussions\n\n## Requirements\n\n### Personal Access Token (PAT)\n\nThis action **requires a Personal Access Token** - the default `GITHUB_TOKEN` will not work because:\n\n- Contribution calendar data requires authentication as the actual user\n- Repository view counts require push access across all repositories\n- The `viewer` GraphQL query returns data for the token owner\n\n#### Required PAT Scopes\n\n| Scope | Purpose |\n|-------|---------|\n| `read:user` | Access user profile data |\n| `repo` | Access repository statistics, views, and private repos |\n\n#### Creating a PAT\n\n1. Go to [GitHub Settings → Developer settings → Personal access tokens → Fine-grained tokens](https://github.com/settings/tokens?type=beta)\n2. Click \"Generate new token\"\n3. Select the scopes listed above\n4. Copy the token and add it as a repository secret (e.g., `USER_PAT`)\n\n## Usage\n\n### Basic Workflow\n\nCreate `.github/workflows/stats.yaml`:\n\n```yaml\nname: Collect GitHub Stats\n\non:\n  schedule:\n    - cron: '0 0 * * *'  # Run daily at midnight\n  workflow_dispatch:      # Allow manual trigger\n\njobs:\n  collect-stats:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: Collect GitHub Stats\n        uses: LukeHagar/stats-action@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.USER_PAT }}\n\n      - name: Commit stats\n        uses: stefanzweifel/git-auto-commit-action@v5\n        with:\n          commit_message: \"chore: update github stats\"\n          file_pattern: github-user-stats.json\n```\n\n### Template Repository\n\nFor a complete setup with visualization, use the [stats template repository](https://github.com/LukeHagar/stats/).\n\n## Output\n\nThe action creates a `github-user-stats.json` file with the following structure:\n\n### Profile Information\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `name` | string | Display name |\n| `username` | string | GitHub username |\n| `avatarUrl` | string | Profile picture URL |\n| `bio` | string \\| null | Profile bio |\n| `company` | string \\| null | Company name |\n| `location` | string \\| null | Location |\n| `email` | string \\| null | Public email |\n| `twitterUsername` | string \\| null | Twitter/X handle |\n| `websiteUrl` | string \\| null | Website URL |\n| `createdAt` | string | Account creation date (ISO 8601) |\n\n### Statistics\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `totalCommits` | number | Total commits (from GitHub search) |\n| `commitCount` | number | Commits from contributor stats |\n| `totalPullRequests` | number | Total PRs created |\n| `totalPullRequestReviews` | number | Total PR reviews |\n| `totalContributions` | number | All-time contributions |\n| `openIssues` | number | Open issues created |\n| `closedIssues` | number | Closed issues created |\n| `discussionsStarted` | number | Discussions started |\n| `discussionsAnswered` | number | Discussion answers marked as correct |\n| `repositoriesContributedTo` | number | Repos contributed to |\n\n### Repository Metrics\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `starCount` | number | Total stars received |\n| `forkCount` | number | Total forks of your repos |\n| `starsGiven` | number | Repos you've starred |\n| `repoViews` | number | Total repo views (last 14 days) |\n\n### Code Statistics\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `linesAdded` | number | Total lines added |\n| `linesDeleted` | number | Total lines deleted |\n| `linesOfCodeChanged` | number | Total lines changed (added + deleted) |\n| `codeByteTotal` | number | Total bytes of code |\n\n### Social\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `followers` | number | Follower count |\n| `following` | number | Following count |\n\n### Languages\n\n```json\n{\n  \"topLanguages\": [\n    {\n      \"languageName\": \"TypeScript\",\n      \"color\": \"#3178c6\",\n      \"value\": 1234567,\n      \"percentage\": 45.5\n    }\n  ]\n}\n```\n\n### Contribution Stats\n\n```json\n{\n  \"contributionStats\": {\n    \"longestStreak\": 42,\n    \"currentStreak\": 7,\n    \"mostActiveDay\": \"Tuesday\",\n    \"averagePerDay\": 3.5,\n    \"averagePerWeek\": 24.5,\n    \"averagePerMonth\": 105.0,\n    \"monthlyBreakdown\": [\n      { \"month\": \"2024-01\", \"contributions\": 120 }\n    ]\n  }\n}\n```\n\n### Top Repositories\n\n```json\n{\n  \"topRepos\": [\n    {\n      \"name\": \"repo-name\",\n      \"description\": \"Repo description\",\n      \"stars\": 100,\n      \"forks\": 25,\n      \"isArchived\": false,\n      \"primaryLanguage\": \"TypeScript\",\n      \"updatedAt\": \"2024-01-15T10:30:00Z\",\n      \"createdAt\": \"2023-06-01T08:00:00Z\"\n    }\n  ]\n}\n```\n\n### Full Contribution Calendar\n\nThe `contributionsCollection` field contains the complete contribution calendar with daily data for building heatmaps.\n\n## Development\n\n### Prerequisites\n\n- [Bun](https://bun.sh) v1.0+\n\n### Setup\n\n```bash\n# Install dependencies\nbun install\n\n# Run locally (requires GITHUB_TOKEN env var)\nexport GITHUB_TOKEN=your_pat_here\nbun run start\n\n# Run tests\nbun test\n\n# Type check\nbun run typecheck\n```\n\n### Project Structure\n\n```\n├── src/\n│   ├── index.ts       # Main action logic\n│   ├── index.test.ts  # Tests\n│   └── Types.ts       # TypeScript type definitions\n├── action.yml         # GitHub Action definition\n├── package.json\n└── tsconfig.json\n```\n\n## License\n\nMIT - see [LICENSE.md](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukehagar%2Fstats-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukehagar%2Fstats-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukehagar%2Fstats-action/lists"}