Search code examples
github-actions

How to make a github workflow error message show up in log and annotations?


I have a workflow step that runs this last stage of a shell command in a loop:

|| echo "::error Filename $filename doesn't match possible files" && exit 1 ; done

The exit is triggered appropriately, but the only annotation I see is:

Error: Process completed with exit code 1.

The log shows the entire shell command pipeline and also that same error message, but not my echo'd error.

How do I get my output, including the $filename variable, included?


Solution

  • You have the wrong syntax:

    echo "::error::Filename $filename doesn't match possible files"

    You need to postfix error with ::

    Here is a working workflow:

    There must be something else wrong with your workflow if it doesn't work - other command is exiting with code 1 before it has a chance to execute.