[GH-ISSUE #573] Enhancement: Fail if env variable is used in strategy of a job #385

Open
opened 2026-03-01 21:42:54 +03:00 by kerem · 4 comments
Owner

Originally created by @pdecat on GitHub (Mar 20, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/573

Originally assigned to: @catthehacker on GitHub.

Describe feature

The following configuration works in act:

name: Python package

on: [push, pull_request]

env:
  target_python_version: 3.8

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 5
      matrix:
        python-version: [3.7, "${{env.target_python_version}}"]

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install tox tox-gh-actions
    - name: Test with tox
      run: tox

but fails in Github Actions:

.github/workflows/main.yml#L14The workflow is not valid. .github/workflows/main.yml (Line: 14, Col: 31): Unrecognized named-value: 'env'. Located at position 1 within expression: env.target_python_version

Sadly, this is not supported:

Originally created by @pdecat on GitHub (Mar 20, 2021). Original GitHub issue: https://github.com/nektos/act/issues/573 Originally assigned to: @catthehacker on GitHub. ## Describe feature The [following configuration](https://github.com/fbradyirl/openwrt-luci-rpc/pull/47/files#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3R1-R27) works in act: ```yaml name: Python package on: [push, pull_request] env: target_python_version: 3.8 jobs: test: runs-on: ubuntu-latest strategy: max-parallel: 5 matrix: python-version: [3.7, "${{env.target_python_version}}"] steps: - uses: actions/checkout@v1 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install tox tox-gh-actions - name: Test with tox run: tox ``` but [fails in Github Actions](https://github.com/fbradyirl/openwrt-luci-rpc/actions/runs/648723692): ``` .github/workflows/main.yml#L14The workflow is not valid. .github/workflows/main.yml (Line: 14, Col: 31): Unrecognized named-value: 'env'. Located at position 1 within expression: env.target_python_version ``` Sadly, this is not supported: * https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#env * https://github.com/actions/runner/issues/480 * https://github.community/t/env-vars-are-not-expanded-causing-dry-violations/16550 * https://github.community/t/how-to-use-env-context/16975/2 * https://github.com/fbradyirl/openwrt-luci-rpc/pull/47
Author
Owner

@github-actions[bot] commented on GitHub (Apr 20, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:822871522 --> @github-actions[bot] commented on GitHub (Apr 20, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@physikerwelt commented on GitHub (May 18, 2021):

I am very new to act and github actions, so my assumption that my issue is related might be wrong. I am seeing at least the same error, if I try to skip an entire workflow locally.
https://github.com/zbMATHOpen/linksApi/blob/master/.github/workflows/codeql-analysis.yml#L27
I wonder if the is a different method people use to determine if the job is executed on github or locally.

<!-- gh-comment-id:843549896 --> @physikerwelt commented on GitHub (May 18, 2021): I am very new to act and github actions, so my assumption that my issue is related might be wrong. I am seeing at least the same error, if I try to skip an entire workflow locally. https://github.com/zbMATHOpen/linksApi/blob/master/.github/workflows/codeql-analysis.yml#L27 I wonder if the is a different method people use to determine if the job is executed on github or locally.
Author
Owner

@catthehacker commented on GitHub (May 18, 2021):

@physikerwelt you don't use environment variables in matrix so it's definitely not the same issue

<!-- gh-comment-id:843554683 --> @catthehacker commented on GitHub (May 18, 2021): @physikerwelt you don't use environment variables in matrix so it's definitely not the same issue
Author
Owner

@ZauberNerd commented on GitHub (Feb 1, 2022):

Check out https://github.com/rhysd/actionlint to lint your workflow files.

<!-- gh-comment-id:1027162585 --> @ZauberNerd commented on GitHub (Feb 1, 2022): Check out https://github.com/rhysd/actionlint to lint your workflow files.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#385
No description provided.