vscode-github-actions icon indicating copy to clipboard operation
vscode-github-actions copied to clipboard

Yaml validation fail when using expession in job env or step env

Open h-haaks opened this issue 6 months ago • 0 comments

Describe the bug I have a workflow that uses a matrix that define env to use with each job. Using expression to set the job env fail validation.

To Reproduce Steps to reproduce the behavior:

  1. Create a workflow file like this
---

on:
  push: {}

jobs:
  myjob:
    strategy:
      matrix:
        include:
          - name: 'env1'
            runs-on: 'ubuntu-22.04'
            env:
              VAR1: 'value1'
              VAR2: 'value2'
          - name: 'env2'
            runs-on: 'ubuntu-24.04'
            env:
              VAR1: 'value3'
              VAR2: 'value4'
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.runs-on }}
    env: ${{ matrix.env }}
    steps:
      - name: Run tests
        run: 'echo "var1: $VAR1, var2: $VAR2"'
  1. See validation error in vscode
`Unexpected type 'BasicExpressionToken' encountered while reading 'job env'. The type 'MappingToken' was expected.`

3: running the workflow produces env1

Run echo "var1: $VAR1, var2: $VAR2"
var1: value1, var2: value2

env2

Run echo "var1: $VAR1, var2: $VAR2"
var1: value3, var2: value4

No errors.

Expected behavior I would expect validation not to produce an error like this

h-haaks avatar Jul 11 '25 13:07 h-haaks