Posting Stats to a Webhook

December 12, 2024 Β· View on GitHub

πŸ”₯ This integration does not require sponsorship. Enjoy!

This action allows you to send results to a webhook of your choice. This means you can integrate with platforms like Zapier, IFTTT, Automate.io, and more, to perform actions based on the results.

How to Use the Webhook Parameter

To use this feature, provide a URL in the webhook parameter. For example:

name: Pull Request Stats

on:
  schedule:
    - cron: '0 16 * * 5'

jobs:
  stats:
    runs-on: ubuntu-latest
    steps:
      - name: Run pull request stats
        uses: flowwer-dev/pull-request-stats@main
        with:
          repositories: 'piedpiper/repo1,piedpiper/repo2'
          webhook: 'https://hooks.zapier.com/hooks/catch/123456/XXXXXXXX'
          # webhook: ${{ secrets.WEBHOOK_URL }} You may want to store this value as a secret.

This configuration calculates pull request stats for the repositories piedpiper/repo1 and piedpiper/repo2 every Friday at 16:00 (UTC). The results are sent to the specified webhook URL via a POST request.

Webhook Payload Structure

The webhook payload includes detailed information:

Parameters

ParameterTypeDescription
entries[]objectA list of objects containing data about each user contributing to the stats.
entries[].userobjectInformation about the user.
entries[].user.idstringGitHub's unique identifier for the user.
entries[].user.urlstringThe URL to the user's GitHub profile.
entries[].user.loginstringGitHub username.
entries[].user.avatarUrlstringURL to the user's profile picture.
entries[].statsobjectSummarized stats for the user based on the selected options.
entries[].contributionsobjectRepresents the proportion of a specific stat attributed to the user. For example, if there are 50 total reviews and the user performed 10, their contribution is 0.2.
entries[].urlsobjectURLs pointing to this action's web-based views.
entries[].urls.timeToReviewstringURL to the user's historic review times.
entries[].reviews[]objectList of reviews performed by the user.
entries[].reviews[].idintegerGitHub ID for the review.
entries[].reviews[].pullRequestIdintegerGitHub ID for the reviewed pull request.
entries[].reviews[].submittedAtdateDate when the review was submitted.
entries[].reviews[].commentsCountintegerNumber of comments made in the review.
entries[].reviews[].timeToReviewintegerTime in milliseconds taken to complete the review.
optionsobjectOptions used to calculate the stats.
options.organizationstringName of the organization analyzed (if repositories are not specified).
options.repositories[]stringNames of the analyzed repositories (if the organization is not specified).
options.periodLengthintegerNumber of days used to calculate the stats.
options.pullRequestIdstringGitHub ID for the pull request that triggered the action, if applicable.

Example Payload

{
  "entries": [
    {
      "user": {
        "id": 1031639,
        "url": "https://github.com/manuelmhtr",
        "login": "manuelmhtr",
        "avatarUrl": "https://avatars.githubusercontent.com/u/1031639"
      },
      "reviews": [
        {
          "submittedAt": "2022-08-23T16:33:59.000Z",
          "id": "PRR_kwDOEwhtk859AhaFB",
          "commentsCount": 0,
          "timeToReview": 861000,
          "pullRequestId": "PR_kwDOEwhtk8491p9nf"
        },
        {
          "submittedAt": "2022-08-25T17:30:33.000Z",
          "id": "PRR_kwDOEwmmhk85Ah1uLoG",
          "commentsCount": 0,
          "timeToReview": 246000,
          "pullRequestId": "PR_kwDOEwmmhk84910CYr"
        }
      ],
      "stats": {
        "totalReviews": 1,
        "totalComments": 0,
        "commentsPerReview": 0,
        "timeToReview": 553500
      },
      "urls": {
        "timeToReview": "https://app.flowwer.dev/charts/review-time/..."
      },
      "contributions": {
        "totalReviews": 0.3,
        "totalComments": 0,
        "commentsPerReview": 0.5,
        "timeToReview": 0.1
      }
    }
  ],
  "options": {
    "periodLength": 30,
    "organization": "flowwer-dev",
    "repositories": null,
    "pullRequestId": "PR_Mhspq3784A10asbbs"
  }
}

What's Next?

We’re building more integrations for this action! Share your ideas about the integrations you'd like to see and how you plan to use webhooks.

Support this project by becoming a sponsor. πŸ’™