[GH-ISSUE #841] Conditional step not running for environment variables (unable to interpolate string) #510

Closed
opened 2026-03-01 21:44:03 +03:00 by kerem · 1 comment
Owner

Originally created by @agonzalezro on GitHub (Oct 15, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/841

System information

  • Operating System: Mac
  • Architecture: x86
  • Docker version: Docker version 20.10.8, build 3967b7d
  • Docker image used in act: lucasalt/act_base:latest
  • act version: 0.2.24

Expected behaviour

It should run a conditional step based on the value of an environment variable.

Actual behaviour

It complains about a syntax error.

[act.yml/test] 🚀  Start image=lucasalt/act_base:latest
[act.yml/test]   🐳  docker run image=lucasalt/act_base:latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[act.yml/test]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root
ERRO[0000] Unable to interpolate string '${{${{ env.TEST != '' }}' - [(anonymous): Line 1:2 Unexpected token { (and 1 more errors)] 
[act.yml/test]   ❌  Error in if: expression - echo "This should run"

Steps to reproduce

cd $(mktemp -d)
mkdir -p .github/workflows
cat > .github/workflows/act.yml << 'EOF'
on: [push]

env:
  TEST: 123

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - if: "${{ env.TEST != '' }}"
        run: echo "This should run"

EOF
git init
git add .
git commit -m "Initial"
git remote add origin does-not-matter
act

act output

Log
DEBU[0000] Loading environment from /var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.env 
DEBU[0000] Loading secrets from /var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.secrets 
DEBU[0000] Loading workflows from '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows' 
DEBU[0000] Loading workflows recursively                
DEBU[0000] Found workflow 'act.yml' in '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows/act.yml' 
DEBU[0000] Reading workflow '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows/act.yml' 
DEBU[0000] Correcting if statements '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows/act.yml' 
DEBU[0000] Planning event: push                         
DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' 
DEBU[0000] using github ref: refs/heads/main            
DEBU[0000] context env => map[ACT:true TEST:123]        
DEBU[0000] context needs => map[]                       
[act.yml/test] 🚀  Start image=lucasalt/act_base:latest
DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' 
DEBU[0000] using github ref: refs/heads/main            
[act.yml/test]   🐳  docker pull lucasalt/act_base:latest
DEBU[0000] Image exists? true                           
[act.yml/test]   🐳  docker create image=lucasalt/act_base:latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[act.yml/test] Created container name=act-act-yml-test id=d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c from image lucasalt/act_base:latest (platform: )
[act.yml/test] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_TEMP=/tmp]
[act.yml/test]   🐳  docker run image=lucasalt/act_base:latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[act.yml/test] Starting container: d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c
[act.yml/test] Started container: d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c
[act.yml/test]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root
[act.yml/test] Exec command '[mkdir -m 0777 -p /var/run/act]'
DEBU[0000] Writing entry to tarball workflow/event.json len:2 
DEBU[0000] Writing entry to tarball workflow/envs.txt len:0 
DEBU[0000] Writing entry to tarball workflow/paths.txt len:0 
[act.yml/test] Extracting content to '/var/run/act/'
DEBU[0000] Evaluating '${{ env['TEST'] != ''' instead of '${{ env.TEST != ''' 
ERRO[0000] Unable to interpolate string '${{${{ env.TEST != '' }}' - [(anonymous): Line 1:2 Unexpected token { (and 1 more errors)] 
[act.yml/test]   ❌  Error in if: expression - echo "This should run"
DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' 
DEBU[0000] using github ref: refs/heads/main            
DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' 
DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 
DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' 
DEBU[0000] using github ref: refs/heads/main            
DEBU[0000] context env => map[ACT:true TEST:123]        
DEBU[0000] context needs => map[]                       
DEBU[0000] context env => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_ENV:/var/run/act/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_PATH:/var/run/act/workflow/paths.txt GITHUB_REF:refs/heads/main GITHUB_REPOSITORY:asd GITHUB_REPOSITORY_OWNER:asd GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:3332287b750600b6ff1d7550499eccda50e05147 GITHUB_TOKEN: GITHUB_WORKFLOW:act.yml GITHUB_WORKSPACE:/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm ImageOS:ubuntu20 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID: TEST:123] 
[act.yml/test] setupEnv => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_ENV:/var/run/act/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_PATH:/var/run/act/workflow/paths.txt GITHUB_REF:refs/heads/main GITHUB_REPOSITORY:asd GITHUB_REPOSITORY_OWNER:asd GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:3332287b750600b6ff1d7550499eccda50e05147 GITHUB_TOKEN: GITHUB_WORKFLOW:act.yml GITHUB_WORKSPACE:/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm ImageOS:ubuntu20 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID: TEST:123]
[act.yml/test] Removed container: d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c
[act.yml/test]   🐳  docker volume rm act-act-yml-test
Originally created by @agonzalezro on GitHub (Oct 15, 2021). Original GitHub issue: https://github.com/nektos/act/issues/841 ## System information <!-- - Operating System: < Windows | Linux | macOS | etc... > - Architecture: < x64 (64-bit) | x86 (32-bit) | arm64 (64-bit) | arm (32-bit) | etc... > - Apple M1: < yes | no > - Docker version: < output of `docker system info -f "{{.ServerVersion}}"` > - Docker image used in `act`: < can be omitted if it's included in log > - `act` version: < output of `act --version`, if you've built `act` yourself, please provide commit hash > --> - Operating System: Mac - Architecture: x86 - Docker version: Docker version 20.10.8, build 3967b7d - Docker image used in `act`: `lucasalt/act_base:latest` - `act` version: 0.2.24 ## Expected behaviour It should run a conditional step based on the value of an environment variable. ## Actual behaviour It complains about a syntax error. ``` [act.yml/test] 🚀 Start image=lucasalt/act_base:latest [act.yml/test] 🐳 docker run image=lucasalt/act_base:latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [act.yml/test] 🐳 docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root ERRO[0000] Unable to interpolate string '${{${{ env.TEST != '' }}' - [(anonymous): Line 1:2 Unexpected token { (and 1 more errors)] [act.yml/test] ❌ Error in if: expression - echo "This should run" ``` ## Steps to reproduce <!-- - Provide workflow with which we can reproduce the issue OR - Provide link to your GitHub repository that contains the workflow <details> <summary>workflow</summary> ```yaml on: [push] env: TEST: 123 jobs: test: runs-on: ubuntu-latest steps: - if: "${{ env.TEST != '' }}" run: echo "This should run" ``` </details> ## Steps to reproduce <!-- - Make sure to include full command with parameters you used to run `act`, example: 1. Clone example repo (https://github.com/cplee/github-actions-demo) 2. Enter cloned repo directory 3. Run `act -s SUPER_SECRET=im-a-value` --> ```bash cd $(mktemp -d) mkdir -p .github/workflows cat > .github/workflows/act.yml << 'EOF' on: [push] env: TEST: 123 jobs: test: runs-on: ubuntu-latest steps: - if: "${{ env.TEST != '' }}" run: echo "This should run" EOF git init git add . git commit -m "Initial" git remote add origin does-not-matter act ``` ## `act` output <!-- - Use `act` with `-v`/`--verbose` and paste output from your terminal in code block below --> <details> <summary>Log</summary> ```none DEBU[0000] Loading environment from /var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.env DEBU[0000] Loading secrets from /var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.secrets DEBU[0000] Loading workflows from '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows' DEBU[0000] Loading workflows recursively DEBU[0000] Found workflow 'act.yml' in '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows/act.yml' DEBU[0000] Reading workflow '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows/act.yml' DEBU[0000] Correcting if statements '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.github/workflows/act.yml' DEBU[0000] Planning event: push DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' DEBU[0000] using github ref: refs/heads/main DEBU[0000] context env => map[ACT:true TEST:123] DEBU[0000] context needs => map[] [act.yml/test] 🚀 Start image=lucasalt/act_base:latest DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' DEBU[0000] using github ref: refs/heads/main [act.yml/test] 🐳 docker pull lucasalt/act_base:latest DEBU[0000] Image exists? true [act.yml/test] 🐳 docker create image=lucasalt/act_base:latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [act.yml/test] Created container name=act-act-yml-test id=d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c from image lucasalt/act_base:latest (platform: ) [act.yml/test] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_TEMP=/tmp] [act.yml/test] 🐳 docker run image=lucasalt/act_base:latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [act.yml/test] Starting container: d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c [act.yml/test] Started container: d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c [act.yml/test] 🐳 docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root [act.yml/test] Exec command '[mkdir -m 0777 -p /var/run/act]' DEBU[0000] Writing entry to tarball workflow/event.json len:2 DEBU[0000] Writing entry to tarball workflow/envs.txt len:0 DEBU[0000] Writing entry to tarball workflow/paths.txt len:0 [act.yml/test] Extracting content to '/var/run/act/' DEBU[0000] Evaluating '${{ env['TEST'] != ''' instead of '${{ env.TEST != ''' ERRO[0000] Unable to interpolate string '${{${{ env.TEST != '' }}' - [(anonymous): Line 1:2 Unexpected token { (and 1 more errors)] [act.yml/test] ❌ Error in if: expression - echo "This should run" DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' DEBU[0000] using github ref: refs/heads/main DEBU[0000] Loading slug from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] Loading revision from git directory '/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm/.git' DEBU[0000] Found revision: 3332287b750600b6ff1d7550499eccda50e05147 DEBU[0000] HEAD points to '3332287b750600b6ff1d7550499eccda50e05147' DEBU[0000] using github ref: refs/heads/main DEBU[0000] context env => map[ACT:true TEST:123] DEBU[0000] context needs => map[] DEBU[0000] context env => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_ENV:/var/run/act/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_PATH:/var/run/act/workflow/paths.txt GITHUB_REF:refs/heads/main GITHUB_REPOSITORY:asd GITHUB_REPOSITORY_OWNER:asd GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:3332287b750600b6ff1d7550499eccda50e05147 GITHUB_TOKEN: GITHUB_WORKFLOW:act.yml GITHUB_WORKSPACE:/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm ImageOS:ubuntu20 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID: TEST:123] [act.yml/test] setupEnv => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_ENV:/var/run/act/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_PATH:/var/run/act/workflow/paths.txt GITHUB_REF:refs/heads/main GITHUB_REPOSITORY:asd GITHUB_REPOSITORY_OWNER:asd GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:3332287b750600b6ff1d7550499eccda50e05147 GITHUB_TOKEN: GITHUB_WORKFLOW:act.yml GITHUB_WORKSPACE:/var/folders/ng/hcryqww546142wdhltj7xsgm0000gp/T/tmp.kflcghpm ImageOS:ubuntu20 PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID: TEST:123] [act.yml/test] Removed container: d77332660cf4d04e4b74518e4c44d69de10d68060576010e5c061dca7144bc4c [act.yml/test] 🐳 docker volume rm act-act-yml-test ``` </details>
kerem 2026-03-01 21:44:03 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 15, 2021):

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

<!-- gh-comment-id:968395772 --> @github-actions[bot] commented on GitHub (Nov 15, 2021): Issue is stale and will be closed in 14 days unless there is new activity
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#510
No description provided.