user989988
user989988

Reputation: 3736

GitHub action to add a condition

I have a build yaml file as follows:

name: CI
on:
  push:
    branches:
    - master
jobs:
  BuildAndRelease:
    strategy:
      matrix:
        BuildConfiguration:
        - debug
        - release
      max-parallel: 2
    runs-on: windows-2019
    steps:   
    - name: List contents of a folder
      run: dir

How do I add a condition in this step?

if: and(succeeded(), eq(variables['BuildConfiguration'], 'debug'))

Upvotes: 1

Views: 532

Answers (1)

riQQ
riQQ

Reputation: 12693

steps:
- name: A conditional step
  if: ${{ success() && matrix.BuildConfiguration == 'debug' }}

The expression syntax, operators and functions are documented here: https://docs.github.com/en/actions/learn-github-actions/expressions

Upvotes: 5

Related Questions