Step run with a condition


I am trying to disable a specific Maven profile under certain conditions.

I’ve been unsuccessfully coming up with many variants of the following run script:

run: |
if [["${{ matrix.neo4j_version }}" == 3.4* || "${{ matrix.neo4j_version }}" == 3.5*]] ; then
EXTRA_ARGS="-P '!with-jetty-workaround'"
mvn --quiet --batch-mode --show-version verify -D"neo4j.version"=${{ matrix.neo4j_version }} -D"neo4j-jdbc.version"=${{ matrix.jdbc_driver_version }} "${EXTRA_ARGS}"

I tried duplicating the script and protecting it with an if guard, with and without the startsWith function, I did not get anything to work.

It immediately fails on windows-latest with:

shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
    JAVA_HOME: C:\hostedtoolcache\windows\jdk\8.0.242\x64
    JAVA_HOME_8.0.242_x64: C:\hostedtoolcache\windows\jdk\8.0.242\x64
##[error]Process completed with exit code 1.

The build runs on ubuntu-latest and macos-latest, but the profile exclusion seems to be ignored.

Any idea on how to make this work on the three OSs?

@fbiville ,

The  if statements you are using is used for  bash scripting to set conditions. So you should select bash shell to execute the scripts.

On Linux and macOS runners, the default shell is bash. But on Windows runners, the default shell is PowerShell , you need to switch the shell to bash

The following is a simple example as reference, I have tested, it can work fine as expected:

    name: Testing and verification
    runs-on: ${{ matrix.os }}
      fail-fast: false
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: [2.7, 3.6, 3.7.6, 3.8.2]
      - name: Checkout
        uses: actions/checkout@v2
          fetch-depth: 2

      - name: Set up Python
        uses: actions/setup-python@v1
          python-version: ${{ matrix.python-version }}

      - name: Check Python version
        shell: bash
        run: |
          if [["${{ matrix.python-version }}" == 3.7* || "${{ matrix.python-version }}" == 3.8*]]; then echo "The specified Python version is ${{ matrix.python-version }}"; fi
          echo "============================================"
          echo "The actual installed Python version is:"
          python --version
          echo "============================================"
          python --help