Skip to content
award

GitHub Action

Sorted PR Checks

v1.0.2 Latest version

Sorted PR Checks

award

Sorted PR Checks

Comments on a pull request with a summary of the checks

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Sorted PR Checks

uses: ipdxco/sorted-pr-checks@v1.0.2

Learn more about this action in ipdxco/sorted-pr-checks

Choose a version

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.pull_requests[0].number }}
  cancel-in-progress: true

jobs:
  comment:
    if: github.event.workflow_run.event == 'pull_reqeust' || 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: '${{ github.event.workflow_run.pull_requests[0].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 }}'