Skip to content

GitHub Action that comments on a pull request with a summary of the checks

Notifications You must be signed in to change notification settings

ipdxco/sorted-pr-checks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Sorted PR Checks

This GitHub Actions reusable workflow and action address the limitation of the GitHub UI, which does not sort or group Pull Request check results. The solution proposed here is to post a sticky comment to the Pull Request with a sorted and, optionally, grouped list of checks. This makes it easier to find failed GitHub Actions jobs at a glance.

If you're interested in this solution, you might also want to check out Refined GitHub Extension. The extension updates the GitHub UI with many long-awaited improvements. In particular, it does sort Pull Request check results by their status.

What does it do?

  1. Retrieve the checks from the pull request
  2. Render the comment with PR checks nicely formatted
  3. Create or update (if it already exists) the comment on a pull request

Note that the templates we provide are configured to comment with Some checks have not completed yet until all the checks are complete. We found this to be a more reliable solution since we cannot easily listen to when individual checks are created/updated.

How can I add it to my repository?

Just add the following workflow to your repository. The workflow uses the reusable workflow defined in this repository. It is triggered whenever a workflow that produces PR checks starts and finishes.

name: Comment with sorted PR checks

on:
  workflow_run:
    workflows:
      # List the workflows triggered on pull_request in your repository here
      - TODO
    types:
      - requested
      - completed

permissions:
  pull-requests: write

concurrency:
  group: ${{ github.workflow }}-${{ github.event.workflow_run.id }}
  cancel-in-progress: true

jobs:
  comment:
    if: github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'pull_request_target'
    uses: ipdxco/sorted-pr-checks/.github/workflows/comment.yml@v1

If you use externally created PR checks in your repository, you might also consider triggering the workflow on events like workflow_run or workflow_suite. Note that those events are not triggered when created with the default GitHub token. That's why we suggest using workflow_run event trigger instead.

If you want to perform other actions alongside posting the comment, the solution is also available as an action. You can use it as follows.

steps:
  - uses: ipdxco/sorted-pr-checks@v1

What templates are available?

The templates directory contains all the available templates. They follow the lodash.template syntax. You can choose one of the ready-made templates or implement one yourself!

sorted_by_result (default)

Screenshot 2024-04-08 at 12 58 28

grouped_by_result

Screenshot 2024-04-08 at 12 58 42

unsuccessful_only

Screenshot 2024-04-11 at 13 14 17

How do I switch between the templates?

Here are all the configuration options. The action and the reusable workflow share the exact same inputs.

with:
  # The repository to comment on
  repository: '${{ github.repository }}'
  # The pull request number
  pull_number: ''
  # The template name or a lodash style template to use for the comment
  template: 'sorted_by_result'
  # The identifier to use for the sticky comment
  identifier: '${{ github.workflow }}-${{ github.job }}'
  # The GitHub token
  token: '${{ github.token }}'

About

GitHub Action that comments on a pull request with a summary of the checks

Resources

Stars

Watchers

Forks

Packages

No packages published