Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub actions: if conditionals in execution of step fails

I want to run a GitHub actions step if an env var matches a value

      - name: send slack failure
        uses: rtCamp/action-slack-notify@v2
        if: env.STATUS_MESSAGE != "Success"

However the above syntax is marked as error:

The workflow is not valid. .github/workflows/file.yaml (Line: 107, Col: 13): Unexpected symbol: '"Success"'. Located at position 23 within

How can I compare the value of the env var to a given value?

like image 357
pkaramol Avatar asked Nov 06 '25 21:11

pkaramol


1 Answers

The correct syntax is:

if: ${{ env.STATUS_MESSAGE != 'Success' }}

${{ and }} are optional

like image 72
Grzegorz Krukowski Avatar answered Nov 09 '25 16:11

Grzegorz Krukowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!