Skip to content

Setting default shell (or other step metadata) conditionally in workflows #27143

Answered by ferdnyc
ferdnyc asked this question in Actions
Discussion options

You must be logged in to vote

Over at my setup-msys2 issue, we did some brainstorming and finally came up with this, which works unexpectedly well.

It uses what appears to be undocumented syntax for the matrix context in the Actions yaml, and its contents will get flagged as containing syntax errors by Github’s web workflow editor. Nevertheless, it works exactly as you’d hope it would. All credit to @eine for coming up with the necessary matrix config wizardry.

jobs:
  build:
    runs-on: ${{ matrix.sys.os }}
    strategy:
      matrix:
        sys:
          - { os: windows-latest, shell: 'msys2 {0}' }
          - { os: ubuntu-latest,  shell: bash  }
          - { os: macos-latest,   shell: bash  }
        compiler:
…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dabrahams
Comment options

@ferdnyc
Comment options

@dabrahams
Comment options

@ferdnyc
Comment options

@dabrahams
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants