A Python-based tool to fetch and analyze GitHub user activity statistics, including pull requests, issues, and discussions. The tool can be run locally or automated via GitHub Actions.
- π Fetch comprehensive user activity statistics from GitHub
- π Configurable lookback period (days)
- π Track pull requests, issues, and discussions
- π€ GitHub Actions workflow for automation
- π Detailed activity reports
- πΎ Export results as artifacts
- π Automatic GitHub Actions step summary integration
- Python 3.11 or higher
- GitHub Personal Access Token (PAT) with appropriate scopes:
repo(for private repositories)read:user(for user data)read:discussion(for discussions)
- Clone the repository:
git clone https://github.com/devops-actions/github-user-stats.git
cd github-user-stats- Install dependencies:
pip install -r requirements.txtRun the script with default settings (user: rajbos, lookback: 30 days):
export GITHUB_TOKEN=your_github_token_here
python fetch_user_stats.pySpecify a different user and lookback period:
python fetch_user_stats.py --username octocat --days 90Or provide the token directly:
python fetch_user_stats.py --username rajbos --days 7 --token your_token_here--username: GitHub username to fetch statistics for (default:rajbos)--days: Number of days to look back (default:30)--token: GitHub personal access token (alternatively, useGITHUB_TOKENenvironment variable)--output-file: Optional path to write the output to a file instead of stdout
Save the statistics report to a file:
python fetch_user_stats.py --username rajbos --days 30 --output-file report.txtThe repository includes a GitHub Actions workflow that automatically fetches user statistics.
The workflow runs:
- Manually: Via workflow dispatch in the Actions tab
- Scheduled: Weekly on Mondays at 9 AM UTC
- On Push: When the script or workflow files are modified
- Go to the Actions tab in your GitHub repository
- Select the "GitHub User Statistics" workflow
- Click "Run workflow"
- Optionally specify:
- Username to analyze (default:
rajbos) - Number of days to look back (default:
30)
- Username to analyze (default:
The workflow:
- Displays statistics in the GitHub Actions logs
- Generates a detailed report file
- Uploads the report as an artifact (retained for 30 days)
- Writes statistics to the GitHub Actions step summary (visible in the workflow run summary page)
When running in GitHub Actions, the script automatically detects the GITHUB_STEP_SUMMARY environment variable and writes the statistics to both the console logs and the step summary. This provides an easy-to-read summary directly on the workflow run page without needing to download artifacts.
After a workflow run completes:
- Go to the workflow run summary page
- View the statistics in the step summary section at the bottom of the page
- Or scroll to the "Artifacts" section and download
user-statistics-reportfor offline viewing
================================================================================
GitHub User Statistics for @rajbos
Name: Rob Bos
Period: Last 30 days (since 2025-11-20)
================================================================================
π Pull Requests: 15
Recent Pull Requests:
β
devops-actions/load-used-actions
Update dependency versions
https://github.com/devops-actions/load-used-actions/pull/123 (2025-12-15)
π’ devops-actions/github-user-stats
Add new statistics feature
https://github.com/devops-actions/github-user-stats/pull/5 (2025-12-10)
π Issues: 8
Recent Issues:
π’ devops-actions/marketplace-checks
Enhancement: Add support for new action types
https://github.com/devops-actions/marketplace-checks/issues/45 (2025-12-18)
π¬ Discussions: 3
Recent Discussions:
π¬ Best practices for GitHub Actions security
https://github.com/community/discussions/67890 (2025-12-12)
================================================================================
Summary:
Total Activity Items: 26
================================================================================
- Never commit your GitHub token to the repository
- Use GitHub Secrets for storing tokens in workflows
- The default
GITHUB_TOKENprovided by GitHub Actions has appropriate permissions for public repositories - For private repositories, you may need to create a PAT with additional scopes
The workflow uses secrets.GITHUB_TOKEN, which is automatically provided by GitHub Actions. No additional configuration is needed for public repositories.
For enhanced permissions or private repositories, create a PAT and add it as a secret named GITHUB_TOKEN in your repository settings.
Edit the default value in the workflow file (.github/workflows/user-stats.yml):
inputs:
days:
description: 'Number of days to look back'
required: false
default: '30' # Change this valueUpdate the default username in the workflow file:
inputs:
username:
description: 'GitHub username to analyze'
required: false
default: 'rajbos' # Change this valueIf you encounter authentication errors:
- Verify your token has the required scopes
- Check that the token hasn't expired
- Ensure the
GITHUB_TOKENenvironment variable is set correctly
GitHub API has rate limits:
- Authenticated requests: 5,000 requests per hour
- The script uses GraphQL API which is more efficient
- If you hit rate limits, wait before retrying or reduce the lookback period
If no activity is found:
- Verify the username is correct
- Check if there's activity in the specified time period
- Ensure the token has access to view the user's activity
The script fetches the most recent 100 items of each type (pull requests, issues, discussions):
- For very active users, some older items within the time period may not be included
- This is a limitation of the GitHub GraphQL API query structure
- The 100-item limit per type typically covers most use cases
- If you need complete historical data, consider reducing the lookback period
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Maintained by DevOps Actions