Causes the build to fail if certain annotations are created. This is useful in
conjuntion with
problem matchers
to fail the workflow on compiler warnings without enabling -Werror
.
required This workflow requires an access token with yet to be determined permissions to
read annotations (but likely checks
and actions
).
required The id of the workflow to check annotations for. For jobs checking their own
annotations, ${{ github.run_id }}
works. For jobs triggered by workflow_run
,
${{ github.event.workflow_run.id }}
finds the run_id
of the run that
triggered this run.
optional A regex filter that causes job failures when it's (partially) matching an annotation whose severity is 'warning' or higher. It matches against the annotation's title and message concatinated. Without a filter, any annotation of severity warning or higher causes a build failure.
A useful regex for gcc is \[-W[A-Za-z\-]+?\]
.
This matches the diagnostic flag hints such as [-Wdeprecated-declarations]
in warning: ‘D’ is deprecated [-Wdeprecated-declarations]
.
An alternative would be to search for warning:
and alike.
Check for annotations within the same workflow
matrix-build-step-with-problem-matcher:
[...]
assert-annotations:
name: Check for compiler warnings
needs: [matrix-build-step-with-problem-matcher]
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
actions: read
steps:
- name: Check for gcc compiler warnings
env:
filter: '\[-W[A-Za-z\-]+?\]'
workflow_id: ${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
uses: root-project/annotation-failure-action@main
Check for annotations from a different workflow using on: workflow_run
.
name: Read annotations
on:
workflow_run:
workflows: [annotation-creating-workflow]
types:
- completed
jobs:
read_annotations:
name: Check for compiler warnings
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
actions: read
steps:
- name: Check for annotations in the run that triggered this
env:
workflow_id: ${{ github.event.workflow_run.id }}
GH_TOKEN: ${{ github.token }}
uses: root-project/annotation-failure-action@main