pkaramol
pkaramol

Reputation: 19422

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?

Upvotes: 4

Views: 569

Answers (1)

Grzegorz Krukowski
Grzegorz Krukowski

Reputation: 19872

The correct syntax is:

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

${{ and }} are optional

Upvotes: 2

Related Questions