Skip to content

Issue: act allows ternary operator in expression #718

Closed
@notmatthancock

Description

@notmatthancock

Act version

act version 0.2.20

Expected behaviour

act shouldn't allow ternary operator syntax inside of an expression

Reference: https://github.community/t/do-expressions-support-ternary-operators-to-change-their-returned-value/18114

Actual behaviour

act does allow ternary operator syntax inside of an expression, and it fails when run as a github action

Workflow and/or repository

workflow
name: CI
on:
  workflow_dispatch:
    inputs:
      arg1:
        description: "hello"
        required: true
      arg2:
        description: "goodbye"
        required: false
        default: "null"
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - name: nice-test 
      run: |
        echo "arg1 = ${{ 1 == 2 ? 'yes' : 'no' }}"

Steps to reproduce

act -j test

act output

Log
DEBU[0000] Loading environment from /home/inno/scratch/docker/github-actions-demo/.env 
DEBU[0000] Loading secrets from /home/inno/scratch/docker/github-actions-demo/.secrets 
DEBU[0000] Loading workflows from '/home/inno/scratch/docker/github-actions-demo/.github/workflows' 
DEBU[0000] Reading workflow '/home/inno/scratch/docker/github-actions-demo/.github/workflows/main.yml' 
DEBU[0000] Planning job: test                           
DEBU[0000] Loading slug from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] Loading revision from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] HEAD points to '5c6f585b1f9d8526c8e1672c5f8f00883b895d93' 
DEBU[0000] HEAD matches refs/heads/master               
DEBU[0000] using github ref: refs/heads/master          
DEBU[0000] context env => map[ACT:true]                 
[CI/test] 🚀  Start image=catthehacker/ubuntu:act-latest
DEBU[0000] Loading slug from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] Loading revision from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] HEAD points to '5c6f585b1f9d8526c8e1672c5f8f00883b895d93' 
DEBU[0000] HEAD matches refs/heads/master               
DEBU[0000] using github ref: refs/heads/master          
[CI/test]   🐳  docker pull catthehacker/ubuntu:act-latest
DEBU[0000] Image exists? true                           
[CI/test]   🐳  docker create image=catthehacker/ubuntu:act-latest entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[CI/test] Created container name=act-CI-test id=05ad9157c88abbf132945c31adf49b570bc150ea67849c59e736ade34f7dfc72 from image catthehacker/ubuntu:act-latest
[CI/test] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_TEMP=/tmp]
[CI/test]   🐳  docker run image=catthehacker/ubuntu:act-latest entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[CI/test] Starting container: 05ad9157c88abbf132945c31adf49b570bc150ea67849c59e736ade34f7dfc72
[CI/test] Started container: 05ad9157c88abbf132945c31adf49b570bc150ea67849c59e736ade34f7dfc72
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 home/.act len:0     
[CI/test] Extracting content to '/github/'
DEBU[0000] Loading slug from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] Loading revision from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] HEAD points to '5c6f585b1f9d8526c8e1672c5f8f00883b895d93' 
DEBU[0000] HEAD matches refs/heads/master               
DEBU[0000] using github ref: refs/heads/master          
DEBU[0000] Loading slug from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] Loading revision from git directory '/home/inno/scratch/docker/github-actions-demo/.git' 
DEBU[0000] Found revision: 5c6f585b1f9d8526c8e1672c5f8f00883b895d93 
DEBU[0000] HEAD points to '5c6f585b1f9d8526c8e1672c5f8f00883b895d93' 
DEBU[0000] HEAD matches refs/heads/master               
DEBU[0000] using github ref: refs/heads/master          
DEBU[0000] context env => map[ACT:true]                 
DEBU[0000] context env => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_ENV:/github/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/github/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_REF:refs/heads/master GITHUB_REPOSITORY:cplee/github-actions-demo GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:5c6f585b1f9d8526c8e1672c5f8f00883b895d93 GITHUB_TOKEN: GITHUB_WORKFLOW:CI GITHUB_WORKSPACE:/github/workspace HOME:/github/home] 
DEBU[0000] setupEnv: map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_ENV:/github/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/github/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_REF:refs/heads/master GITHUB_REPOSITORY:cplee/github-actions-demo GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:5c6f585b1f9d8526c8e1672c5f8f00883b895d93 GITHUB_TOKEN: GITHUB_WORKFLOW:CI GITHUB_WORKSPACE:/github/workspace HOME:/github/home] 
[CI/test] ⭐  Run nice-test
DEBU[0000] Wrote command 'echo "arg1 = no"
' to 'workflow/0' 
DEBU[0000] Writing entry to tarball workflow/0 len:17   
[CI/test] Extracting content to '/github/'
[CI/test] Exec command '[bash --noprofile --norc -eo pipefail /github/workflow/0]'
| arg1 = no
[CI/test]   ✅  Success - nice-test
[CI/test] Removed container: 05ad9157c88abbf132945c31adf49b570bc150ea67849c59e736ade34f7dfc72
[CI/test]   🐳  docker volume rm act-CI-test```

</details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't workingneeds-workExtra attention is neededstale-exemptExempt from stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions