Github action to print relevant stats about Pull Request.
The objective of this action is to:
- Track and increase your team's performance.
- Reduce the time taken to review the pull requests.
- Encourage quality on reviews.
- Help to decide which people to assign as reviewers.
Running this action will add a section at the bottom of your pull requests description:
Each reviewer has a link pointing to their historical behavior of each reviewer:
Or send the data to your favorite tools by using the integrations available:
![]() Slack |
![]() MS Teams |
![]() Webhooks |
|---|
- No repository data is collected, stored, or distributed by this GitHub action. This action is state-less.
- Charts data is sent over the URL and never stored or transmitted anywhere else.
- Minimal data is sent to Mixpanel in order to improve this action. However, you can opt-out using the
telemetryoption.
Just add this action to one of your workflow files:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@mainIf you are getting an empty table or an error, check the troubleshooting section.
The possible inputs for this action are:
| Parameter | Description | Default |
|---|---|---|
token |
A Personal Access Token with repo permissions. Required to calculate stats for an organization or multiple repositories. |
GITHUB_TOKEN |
repositories |
A comma-separated list of GitHub repositories to calculate the stats, e.g. username/repo1,username/repo2. If no repositories are specified, the action defaults to the repository where the workflow is running. When specifying other repo(s), it is mandatory to pass a Personal Access Token in the token parameter. |
Current repository |
organization |
If you prefer, you may specify your organization's name to calculate the stats across all of its repositories. When specifying an organization, it is mandatory to pass a Personal Access Token in the token parameter. |
null |
period |
The period used to calculate the stats, expressed in days. | 30 |
limit |
The maximum number of rows to display in the table. A value of 0 means unlimited. |
0 |
stats |
A comma-separated list of stats to calculate and display. Possible values: totalReviews, timeToReview, totalComments, etc... (Check all available in the Stats section) |
totalReviews,timeToReview,totalComments |
charts |
Whether to add a chart to the start. Possible values: true or false. |
false |
disableLinks |
If true, removes the links to the detailed charts. Possible values: true or false. |
false |
sortBy |
The column used to sort the data. Possible values: totalReviews, timeToReview, totalComments, commentsPerReview, openedPullRequests. |
totalReviews |
publishAs |
Where to publish the results. Possible values: COMMENT, DESCRIPTION, or NONE. |
COMMENT |
exclude |
A comma-separated list of usernames (case-insensitive) to be excluded from the results (e.g. username1,username2), or a regular expression enclosed between slashes (e.g. /^bot/i will exclude all usernames that begin with "bot"). |
null |
include |
A comma-separated list of usernames (case-insensitive) to be the only ones included in the results (e.g. username1,username2), or a regular expression enclosed between slashes (e.g. /^bot/i will include only usernames that begin with "bot"). |
null |
telemetry |
Indicates if the action is allowed to send monitoring data to the developer. This data is minimal and helps improve this action. This option is a premium feature reserved for sponsors. | true |
slackWebhook |
A Slack webhook URL to post resulting stats. This option is a premium feature reserved for sponsors. See full documentation here. | null |
slackChannel |
The Slack channel where stats will be posted. Include the # character (e.g. #mychannel). Required when a slackWebhook is configured. |
null |
teamsWebhook |
A Microsoft Teams webhook URL to post resulting stats. This option is a premium feature reserved for sponsors. See full documentation here. | null |
webhook |
A webhook URL to send the resulting stats as JSON (integrate with Zapier, IFTTT...). See full documentation here. | null |
This action outputs the following variables:
| Variable | Description |
|---|---|
resultsMd |
The resulting stats stored as a step output variable in Markdown format. |
resultsJson |
The resulting stats stored as a step output variable in JSON format. |
Minimal config
Add this to the file .github/workflows/stats.yml in your repo:
name: Pull Request Stats
on:
pull_request:
types: [opened]
jobs:
stats:
runs-on: ubuntu-latest
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@mainThis config will:
- Calculate the reviewer stats for the current repo in the lasts 30 days.
- Add links to the historical data.
- Sort results by the "total reviews" column by default.
and print a table like this:
| User | Total reviews | Median time to review | Total comments | |
|---|---|---|---|---|
| jartmez | 37 | 22m | 13 | |
| manuelmhtr | 35 | 48m | 96 | |
| ernestognw | 25 | 1h 27m | 63 | |
| javierbyte | 12 | 30m | 0 | |
| Phaze1D | 4 | 34m | 1 |
Visual config
Add this to the file .github/workflows/stats.yml:
name: Pull Request Stats
on:
pull_request:
types: [opened]
jobs:
stats:
runs-on: ubuntu-latest
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@main
with:
token: ${{ secrets.ADD_A_PERSONAL_ACCESS_TOKEN }}
organization: 'piedpiper'
period: 7
charts: true
disableLinks: true
sortBy: 'totalComments'
stats: 'totalComments,openedPullRequests,totalReviews'This config will:
- Calculate the reviewer stats for all the repos in the "piedpiper" organization in the lasts 7 days.
- Display charts for the metrics.
- Remove the links to detailed charts.
- Sort results by the "Total comments" column.
- Show the "Total comments", "Opened pull requests"and "Median time to review" columns (in that order).
and print a table like this:
This section explains the available stats that can be displayed using the stats option and how they are calculated.
Stats related to the review process:
| Stat name and ID | Description |
|---|---|
Total reviews (totalReviews): |
The total number of pull requests reviewed by a user during the specified period. |
Total comments (totalComments): |
The number of comments made while reviewing other users' Pull Requests during the specified period. Excludes comments made on your own pull requests or general discussions; only code-related comments are included. |
Time to review (timeToReview): |
The median time a reviewer takes from the Pull Request publication or the last commit push (whatever happens last) to the first time the pull request is reviewed. |
Comments per review (commentsPerReview): |
The median number of comments a reviewer made per pull request. |
Reviewed additions (reviewedAdditions): |
The total number of added lines reviewed. |
Reviewed deletions (reviewedDeletions): |
The total number of deleted lines reviewed. |
Reviewed lines (reviewedLines): |
The total number of lines reviewed (additions + deletions). |
Stats related to the production process (opened pull requests):
| Stat name and ID | Description |
|---|---|
Opened pull requests (openedPullRequests): |
The number of pull requests opened by the user in the period. |
Total observations (totalObservations): |
The total number of comments received on pull requests opened by the user. |
Median observations (medianObservations): |
The median number of comments received per pull request opened by the user. |
Revision success rate (revisionSuccessRate): |
The percentage of pull request reviews resulting in approval, compared to the total reviews received. (eg. After 2 "Comment", 4 "Request changes" and 3 "Approve" reviews, the success rate would be 0.33) |
Additions (additions): |
The total number of added lines across the opened pull requests. |
Deletions (deletions): |
The total number of deleted lines across the opened pull requests. |
Lines (lines): |
The total number of lines changed (added and deleted) across all pull requests opened by the user. |
Check the guide for the tool you want to integrate:
The action is printing an empty table.
- Make sure the repositories have pull request reviews during the configured
period. - When specifying
repositoriesororganizationparameters, a Personal Access Token is required in thetokenparameter. - If providing a Personal Access Token, ensure it has the
repopermission for the projects you want. - If you are not providing a Personal Access Token (thus, the action is using the default
GITHUB_TOKEN), make sure the job has thecontents: readandpull-requests: writepermissions While these permissions are typically provided by default, certain organizations may customize or overwrite them.
jobs:
stats:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@mainI get the error "Error commenting on the pull request...".
This error happens when the organization configures the action's permissions as read. To fix it, overwrite them by adding a permissions configuration in the workflow file. The minimum required permissions are contents: read and pull-requests: write:
jobs:
stats:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@mainI'm a sponsor but still getting the error "...is a premium feature, available to sponsors".
- Check the sponsorship comes from the account that owns the configured repos (usually an organization).
- Make sure the sponsorship is configured as
public, otherwise, the action cannot access the sponsorship information. If you prefer to keep itprivate, please reach me out to make it work for you that way π.
This action offers some premium features only for sponsors:
- Disabling telemetry.
- Slack integration.
- Microsoft Teams integration.
- Coming soon: Discord integration, web version.
The suggested sponsorship is $20 USD / month. However, if it's not possible for you or your organization, please consider supporting it with any amount you can. Even a one-time sponsorship will enable the Premium features and encourage the progress of this project.
Being a sponsor will also give you access to the premium features in all of my other projects.
Thanks for your support! π
- Recap: Tired of writing pull request descriptions? Let GPT do it for you.
Used by hundreds of successful teams:
Sixt |
Lululemon |
Delivery H |
JOKR |
Lego |
LOOP |
Hatch |
Zenfi |
|---|---|---|---|---|---|---|---|
Intel |
Auth0 |
Addition |
Fauna |
CDC |
Wecasa |
Bolt |
Republic |
| @manuelmhtr π²π½ Guadalajara, MX |
|
|---|---|
| @CarlosCRG19 π²π½ Colima, MX |
This project is maintained by a small team, considering supporting the project by:
Breaking News! Weβve unleashed the stand-alone version of this action!
- Filter by repositories and date range.
- Stats tracking over the time.
- Tons of new features coming soon!
MIT






