The github-pr-comments
CLI command fetches merged pull request comments from a GitHub repository filtered by milestone and keywords. It aggregates tester contributions and outputs a markdown report of who tested which PRs.
- Fetches only merged PRs for a specific repository, base branch, and milestone.
- Optional date filter (
--merged-since
): include only PRs merged on or after a givenYYYY-MM-DD
date. - Supports keyword filtering, requiring one or more phrases to appear in each comment.
- Collects and groups comments by author, ensuring each PR is listed once per tester.
- Outputs results to the console and writes a
collaborator-tester.md
markdown file. - Configurable via CLI options or environment variables for maximum flexibility.
-
Clone the repository
git clone https://github.com/your_org/your_repo.git
-
Install dependencies with Composer:
composer install
-
Configure
.env
in the project root:GITHUB_TOKEN=your_token_here GITHUB_OWNER=your_org GITHUB_REPO=your_repo GITHUB_BASE=main GITHUB_MILESTONE=v1.0.0 GITHUB_KEYWORDS="I have tested this item, OK to merge"
- Replace
your_token_here
with your GitHub personal access token.
You can find an example
.env
file in this respository. So you could also simply copy this and adapt it to your needs.cp .env.example .env
- Replace
Tip
Store your GitHub token in a CI secret or environment variable rather than in .env
to keep it secure. Ensure your token has read-only permissions (e.g., public_repo
).
- Run the command:
php cli/github-pr-comments.php \ --token=your_token_here \ --owner=your_org \ --repo=your_repo \ --base=main \ --milestone=v1.0.0 \ --merged-since=2023-01-01 \ --keyword="I have tested this item" \ --keyword="OK to merge"
Tip
The merged-since
date filter is optional and especially useful if you have a milestone with multiple releases (alpha, beta, etc.) and want to reflect the tests accurately.
- Authentication via GitHub token in header.
- GraphQL search queries GitHub API for issues of type PR matching repo, base branch, and milestone.
- Pagination loops until all results are fetched (handles
hasNextPage
). - Filtering iterates PR comments and checks if all keywords are present.
- Aggregation groups unique PR entries per author to avoid duplicates.
- Output writes a human-readable list to console and a markdown report file.
php cli/github-pr-comments.php --merged-since=2023-01-01 --milestone=v1.0.0 --keyword="tested" --keyword="LGTM"
Get a list of all possible options:
php cli/github-pr-comments.php github-pr-comments --help
Result
-
Console prints:
- Tests by alice:
- PR #123: Fix typo
- PR #124: Improve validation
- Tests by bob:
- PR #122: Add logging
- Tests by alice:
-
collaborator-tester.md
is created with the grouped results.Thank you to all the testers who help us maintain high quality standards and deliver a robust product.
@alice (2), @bob (1)