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.
- Retrieve the checks from the pull request
- Render the comment with PR checks nicely formatted
- 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.
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
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!
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 }}'