This script generates comprehensive reports showing all pull requests merged into a specified branch (defaults to develop) across all repositories in a GitHub organization. Useful for compliance audits, code review tracking, and change management documentation.
Works with any GitHub organization and branch - just specify the organization name and optionally the branch name when running the script.
- Automatic Repository Discovery: Scans all repositories in the organization
- Smart Filtering: Only processes repositories with the specified branch (default:
develop) and PRs in the date range - Pagination Support: Handles repositories with more than 1000 merged PRs
- Interactive Wizard Mode: Run without arguments for a guided, step-by-step experience
- Progress Indicators: Visual feedback during long-running operations
- Comprehensive Reports: Each report includes:
- Command executed to fetch the data
- Timestamp of when the command was run
- Total number of PRs merged into the specified branch
- Complete list of PRs with details (Number, Title, Branch, Merged At, Author, URL, Reviewers Requested, Approvals)
- Pagination details (how many pages were fetched)
- Multiple Output Formats:
- CSV format (always generated)
- PDF format (if pandoc or wkhtmltopdf is installed)
Before using this script, ensure you have the following installed:
-
GitHub CLI (
gh) - Required for API access# macOS brew install gh # Linux (Ubuntu/Debian) sudo apt-get install gh # Or download from: https://cli.github.com/
-
jq - Required for JSON processing
# macOS brew install jq # Linux (Ubuntu/Debian) sudo apt-get install jq
-
GitHub CLI Authentication - Required to access repositories
gh auth login
Follow the prompts to authenticate with your GitHub account.
-
Clone or download this repository:
git clone <repository-url> cd github-pr-reporter
-
Make the script executable:
chmod +x github_pr_report.sh
-
Verify the script is executable:
ls -l github_pr_report.sh
You should see
-rwxr-xr-x(thexindicates executable permissions). -
Test the installation:
./github_pr_report.sh --help
This should display the help message.
Simply run the script without any arguments to enter interactive mode:
./github_pr_report.shThe script will prompt you for each required parameter:
- Start date
- End date (optional, defaults to today)
- Organization name
- Branch name (optional, defaults to 'develop')
- Repositories to skip (optional)
You can also provide all arguments directly:
# With both start and end dates (uses default 'develop' branch)
./github_pr_report.sh --start-date 2024-11-01 --end-date 2025-10-31 --org MyOrganization
# With only start date (end date defaults to today, branch defaults to 'develop')
./github_pr_report.sh --start-date 2024-11-01 --org MyOrganization
# With custom branch (e.g., 'main' or 'master')
./github_pr_report.sh --start-date 2024-11-01 --org MyOrganization --branch main
# With all options specified
./github_pr_report.sh --start-date 2024-11-01 --end-date 2025-10-31 --org MyOrganization --branch master
# Excluding specific repositories
./github_pr_report.sh --start-date 2024-11-01 --org MyOrganization --skip-repos project_x,project_y
# Combining options
./github_pr_report.sh --start-date 2024-11-01 --org MyOrganization --branch main --skip-repos old-repo,test-repo
# Show help
./github_pr_report.sh --help--start-date DATE(required): Start date in YYYY-MM-DD format--end-date DATE(optional): End date in YYYY-MM-DD format. If not provided, defaults to today's date--org ORG(required): GitHub organization name--branch BRANCH(optional): Branch name to check for merged PRs. Defaults todevelopif not specified--skip-repos LIST(optional): Comma-separated list of repository names to exclude from the report
Reports are saved in a timestamped directory: pr_reports_YYYYMMDD_HHMMSS/
Each repository with merged PRs will have:
{repo_name}_PR_Report.csv- CSV format report{repo_name}_PR_Report.pdf- PDF format (if pandoc is available)
A summary file 00_SUMMARY.txt is also generated with overall statistics.
PDF generation requires both pandoc and a PDF engine. The script will automatically detect available tools.
# macOS
brew install pandoc
brew install basictex # or mactex for full LaTeX distribution
# After installing basictex, you may need to add it to PATH:
# export PATH="/Library/TeX/texbin:$PATH"
# Linux (Ubuntu/Debian)
sudo apt-get install pandoc texlive-latex-base texlive-fonts-recommended# macOS
brew install pandoc weasyprint
# Linux
sudo apt-get install pandoc weasyprint# macOS
brew install pandoc wkhtmltopdf
# Linux
sudo apt-get install pandoc wkhtmltopdfNote: If pandoc is installed but no PDF engine is found, the script will show a helpful message and only generate CSV reports. The script will automatically detect which tools are available and use the best option.
Each report includes:
-
Header Information:
- Repository name
- Organization
- Report generation timestamp
- Date range requested (as provided by user)
- Branch name (as specified, defaults to develop)
-
Command Executed: The exact GitHub API command used to fetch the data
-
Execution Details:
- Timestamp
- Total PRs merged
- Number of pages fetched
- Whether pagination was required
-
Pull Request Summary Table:
- PR Number
- Title
- Branch name
- Merged timestamp
- Author
- URL
- Reviewers requested count
- Approvals count
These reports can be used for:
- Compliance Audits: Document that all PRs merged into develop have gone through the review process
- Code Review Tracking: Track review processes and ensure they are documented and traceable
- Change Management: Maintain records of all changes with timestamps and authors
- Process Documentation: Generate evidence of development workflows and review practices