nektos / act

Run your GitHub Actions locally πŸš€

Home Page:https://nektosact.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent and sometimes broken expression evaluation

iby opened this issue Β· comments

Bug report info

act version:            0.2.57
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 14
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	$HOME/.colima/docker.sock
Config files:           
	/Users/iby/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.21.5
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.57
		DefaultGODEBUG:       panicnil=1
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               arm64
		GOOS:                 darwin

Command used with act

act

Describe issue

Check out the following workflow. There are 3 scenarios all of which should work. I'm trying to use a variable with expression to control job execution via if.

But the first one doesn't, where the variable uses an expression, and then there's another expression references it. Interestingly, the 2nd variation does work:

if: ${{ env.VAR == 'foo' }} # ❌
if: ${{ env.VAR }} == 'foo' # βœ…

But everything works as expected with plain variables, e.g., VAR: 'foo' vs. VAR: ${{ true && 'foo' || 'bar' }}.

I'm guessing act might be interpreting values "on demand" and this doesn't happen as expected inside a "nested" expression?

Link to GitHub repository

No response

Workflow content

on:
  push:

# ❌ VAR expression
env:
  VAR: ${{ true && 'foo' || 'bar' }}
jobs:
  job-1:
    runs-on: ubuntu-latest
    steps:
      - run: echo $VAR
  job-2:
    runs-on: ubuntu-latest
    if: ${{ env.VAR == 'foo' }}
    steps:
      - run: echo $VAR

# βœ… VAR expression
#env:
#  VAR: ${{ true && 'foo' || 'bar' }}
#jobs:
#  job-1:
#    runs-on: ubuntu-latest
#    steps:
#      - run: echo $VAR
#  job-2:
#    runs-on: ubuntu-latest
#    if: ${{ env.VAR  }} == 'foo'
#    steps:
#      - run: echo $VAR

# βœ… Plain VAR
#env:
#  VAR: 'foo'
#jobs:
#  job-1:
#    runs-on: ubuntu-latest
#    steps:
#      - run: echo $VAR
#  job-2:
#    runs-on: ubuntu-latest
#    if: ${{ env.VAR == 'foo' }}
#    steps:
#      - run: echo $VAR

Relevant log output

WARN  ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠  
DEBU[0000] Loading environment from /Users/iby/Development/Bitwild/Gifox-API/.env 
DEBU[0000] Conditional GET for notices etag=0d74acbc-ddfd-402b-b9ab-0bc2a14ca5bd 
DEBU[0000] Loading action inputs from /Users/iby/Development/Bitwild/Gifox-API/.input 
DEBU[0000] Loading secrets from /Users/iby/Development/Bitwild/Gifox-API/.secrets 
DEBU[0000] Loading vars from /Users/iby/Development/Bitwild/Gifox-API/.vars 
DEBU[0000] Evaluated matrix inclusions: map[]           
DEBU[0000] Loading workflows from '/Users/iby/Development/Bitwild/Gifox-API/.github/workflows' 
DEBU[0000] Loading workflows recursively                
DEBU[0000] Found workflow 'main.yml' in '/Users/iby/Development/Bitwild/Gifox-API/.github/workflows/main.yml' 
DEBU[0000] Reading workflow '/Users/iby/Development/Bitwild/Gifox-API/.github/workflows/main.yml' 
DEBU[0000] Preparing plan with all jobs                 
DEBU[0000] Using the only detected workflow event: push 
DEBU[0000] Planning jobs for event: push                
DEBU[0000] gc: 2024-01-12 16:22:40.045243 +0000 GMT m=+0.003659501  module=artifactcache
DEBU[0000] Plan Stages: [0x1400000e3f0]                 
DEBU[0000] Stages Runs: [job-1 job-2]                   
DEBU[0000] Job.Name: job-1                              
DEBU[0000] Job.RawNeeds: {0 0    <nil> []    0 0}       
DEBU[0000] Job.RawRunsOn: {8 0 !!str ubuntu-latest  <nil> []    9 14} 
DEBU[0000] Job.Env: {0 0    <nil> []    0 0}            
DEBU[0000] Job.If: {0 0  success()  <nil> []    0 0}    
DEBU[0000] Job.Steps: echo $VAR                         
DEBU[0000] Job.TimeoutMinutes:                          
DEBU[0000] Job.Services: map[]                          
DEBU[0000] Job.Strategy: <nil>                          
DEBU[0000] Job.RawContainer: {0 0    <nil> []    0 0}   
DEBU[0000] Job.Defaults.Run.Shell:                      
DEBU[0000] Job.Defaults.Run.WorkingDirectory:           
DEBU[0000] Job.Outputs: map[]                           
DEBU[0000] Job.Uses:                                    
DEBU[0000] Job.With: map[]                              
DEBU[0000] Job.Result:                                  
DEBU[0000] Empty Strategy, matrixes=[map[]]             
DEBU[0000] Job Matrices: [map[]]                        
DEBU[0000] Runner Matrices: map[]                       
DEBU[0000] Final matrix after applying user inclusions '[map[]]' 
DEBU[0000] Loading revision from git directory          
DEBU[0000] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32 
DEBU[0000] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32' 
DEBU[0000] using github ref: refs/heads/main            
DEBU[0000] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32 
DEBU[0000] Stages Runs: [job-1 job-2]                   
DEBU[0000] Job.Name: job-2                              
DEBU[0000] Job.RawNeeds: {0 0    <nil> []    0 0}       
DEBU[0000] Job.RawRunsOn: {8 0 !!str ubuntu-latest  <nil> []    13 14} 
DEBU[0000] Job.Env: {0 0    <nil> []    0 0}            
DEBU[0000] Job.If: {8 0 !!str ${{ env.VAR == 'foo' }}  <nil> []    14 9} 
DEBU[0000] Job.Steps: echo $VAR                         
DEBU[0000] Job.TimeoutMinutes:                          
DEBU[0000] Job.Services: map[]                          
DEBU[0000] Job.Strategy: <nil>                          
DEBU[0000] Job.RawContainer: {0 0    <nil> []    0 0}   
DEBU[0000] Job.Defaults.Run.Shell:                      
DEBU[0000] Job.Defaults.Run.WorkingDirectory:           
DEBU[0000] Job.Outputs: map[]                           
DEBU[0000] Job.Uses:                                    
DEBU[0000] Job.With: map[]                              
DEBU[0000] Job.Result:                                  
DEBU[0000] Empty Strategy, matrixes=[map[]]             
DEBU[0000] Job Matrices: [map[]]                        
DEBU[0000] Runner Matrices: map[]                       
DEBU[0000] Final matrix after applying user inclusions '[map[]]' 
DEBU[0000] Loading revision from git directory          
DEBU[0000] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32 
DEBU[0000] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32' 
DEBU[0000] using github ref: refs/heads/main            
DEBU[0000] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32 
DEBU[0000] Detected CPUs: 14                            
[main.yml/job-1] [DEBUG] evaluating expression 'success()'
[main.yml/job-2] [DEBUG] evaluating expression '${{ env.VAR == 'foo' }}'
[main.yml/job-2] [DEBUG] expression '${{ env.VAR == 'foo' }}' evaluated to 'false'
[main.yml/job-2] [DEBUG] Skipping job 'job-2' due to '${{ env.VAR == 'foo' }}'
[main.yml/job-1] [DEBUG] expression 'success()' evaluated to 'true'
[main.yml/job-1] πŸš€  Start image=catthehacker/ubuntu:act-latest
INFO[0000] Parallel tasks (0) below minimum, setting to 1 
[main.yml/job-1]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[main.yml/job-1] [DEBUG]   🐳  docker pull catthehacker/ubuntu:act-latest
[main.yml/job-1] [DEBUG] pulling image 'docker.io/catthehacker/ubuntu:act-latest' ()
DEBU[0000] Saving notices etag=0d74acbc-ddfd-402b-b9ab-0bc2a14ca5bd 
DEBU[0000] No new notices                               
[main.yml/job-1] [DEBUG] Pulling from catthehacker/ubuntu :: act-latest
[main.yml/job-1] [DEBUG] Digest: sha256:6c9a10136ac0a6f40261839b097bb42f438b261480aa50077ccdda3b3581a6c4 :: 
[main.yml/job-1] [DEBUG] Status: Image is up to date for catthehacker/ubuntu:act-latest :: 
INFO[0001] Parallel tasks (0) below minimum, setting to 1 
[main.yml/job-1]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[main.yml/job-1] [DEBUG] Common container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[] Tty:true OpenStdin:false StdinOnce:false Env:[RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=ARM64 RUNNER_TEMP=/tmp LANG=C.UTF-8] Cmd:[] Healthcheck:<nil> ArgsEscaped:false Image:catthehacker/ubuntu:act-latest Volumes:map[] WorkingDir:/Users/iby/Development/Bitwild/Gifox-API Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]}
[main.yml/job-1] [DEBUG] Common container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:host PortBindings:map[] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:<nil> OomKillDisable:<nil> PidsLimit:<nil> Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[{Type:volume Source:act-toolcache Target:/toolcache ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:act-main-yml-job-1-cb7cdf2fa397e45c28079e95c784b2118afd36bb099175c0d931f72fbff58995-env Target:/var/run/act ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:act-main-yml-job-1-cb7cdf2fa397e45c28079e95c784b2118afd36bb099175c0d931f72fbff58995 Target:/Users/iby/Development/Bitwild/Gifox-API ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>}] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>}
[main.yml/job-1] [DEBUG] input.NetworkAliases ==> [job-1]
[main.yml/job-1] [DEBUG] Created container name=act-main-yml-job-1-cb7cdf2fa397e45c28079e95c784b2118afd36bb099175c0d931f72fbff58995 id=8f35a0a6805e31573c3c8771d3506ab969798c58dbbcb494dbb6747150fd060a from image catthehacker/ubuntu:act-latest (platform: )
[main.yml/job-1] [DEBUG] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=ARM64 RUNNER_TEMP=/tmp LANG=C.UTF-8]
[main.yml/job-1]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[main.yml/job-1] [DEBUG] Starting container: 8f35a0a6805e31573c3c8771d3506ab969798c58dbbcb494dbb6747150fd060a
[main.yml/job-1] [DEBUG] Started container: 8f35a0a6805e31573c3c8771d3506ab969798c58dbbcb494dbb6747150fd060a
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/event.json len:2
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/envs.txt len:0
[main.yml/job-1] [DEBUG] Extracting content to '/var/run/act/'
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] expression '${{ true && 'foo' || 'bar' }}' rewritten to 'format('{0}', true && 'foo' || 'bar')'
[main.yml/job-1] [DEBUG] evaluating expression 'format('{0}', true && 'foo' || 'bar')'
[main.yml/job-1] [DEBUG] expression 'format('{0}', true && 'foo' || 'bar')' evaluated to '%!t(string=foo)'
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://192.168.1.246:62251/ APPCAST_URL:https://d1fqctmfkpkkcg.cloudfront.net/gifox/appcast.xml CI:true DATABASE_CA: DATABASE_URL:postgres://postgres:postgres@localhost:5432/gifox?sslmode=disable DBMATE_MIGRATIONS_DIR:source/sql DBMATE_MIGRATIONS_TABLE:migration DBMATE_SCHEMA_FILE:source/sql/schema.sql GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: 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:job-1 GITHUB_REF:refs/heads/main GITHUB_REF_NAME:main GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:Bitwild/Gifox-API GITHUB_REPOSITORY_OWNER:Bitwild GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:239120349b5b127a1b2f86e824ca327acc725e32 GITHUB_WORKFLOW:main.yml GITHUB_WORKSPACE:/Users/iby/Development/Bitwild/Gifox-API IPSTACK_API_SECRET_A: IPSTACK_API_SECRET_B: IPSTACK_API_SECRET_C: ImageOS:ubuntu20 NODE_ENV:development PADDLE_API_SECRET: PADDLE_SANDBOX:true PADDLE_VENDOR_ID: PORT:3000 RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID: SENDGRID_API_SECRET: VAR:foo]
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] evaluating expression ''
[main.yml/job-1] [DEBUG] expression '' evaluated to 'true'
[main.yml/job-1] ⭐ Run Main echo $VAR
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/outputcmd.txt len:0
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/statecmd.txt len:0
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/pathcmd.txt len:0
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/envs.txt len:0
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/SUMMARY.md len:0
[main.yml/job-1] [DEBUG] Extracting content to '/var/run/act'
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] Wrote command 

echo $VAR

 to 'workflow/0'
[main.yml/job-1] [DEBUG] Writing entry to tarball workflow/0 len:11
[main.yml/job-1] [DEBUG] Extracting content to '/var/run/act'
[main.yml/job-1]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[main.yml/job-1] [DEBUG] Exec command '[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0]'
[main.yml/job-1] [DEBUG] Working directory '/Users/iby/Development/Bitwild/Gifox-API'
| foo
[main.yml/job-1]   βœ…  Success - Main echo $VAR
[main.yml/job-1] Cleaning up container for job job-1
[main.yml/job-1] [DEBUG] Removed container: 8f35a0a6805e31573c3c8771d3506ab969798c58dbbcb494dbb6747150fd060a
[main.yml/job-1] [DEBUG]   🐳  docker volume rm act-main-yml-job-1-cb7cdf2fa397e45c28079e95c784b2118afd36bb099175c0d931f72fbff58995
[main.yml/job-1] [DEBUG]   🐳  docker volume rm act-main-yml-job-1-cb7cdf2fa397e45c28079e95c784b2118afd36bb099175c0d931f72fbff58995-env
[main.yml/job-1] 🏁  Job succeeded
[main.yml/job-1] [DEBUG] Loading revision from git directory
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32
[main.yml/job-1] [DEBUG] HEAD points to '239120349b5b127a1b2f86e824ca327acc725e32'
[main.yml/job-1] [DEBUG] using github ref: refs/heads/main
[main.yml/job-1] [DEBUG] Found revision: 239120349b5b127a1b2f86e824ca327acc725e32

Additional information

No response

Edit: The second option actually completely incorrectly evaluates to true… 😰

on:
  push:
env:
  VAR: ${{ true && 'foo' || 'bar' }}
jobs:
  job-1:
    runs-on: ubuntu-latest
    steps:
      - run: echo $VAR
  job-2:
    runs-on: ubuntu-latest
    if: ${{ env.VAR  }} == 'hello world'
    steps:
      - run: echo $VAR

All posted workflows in this issue are incorrect and wouldn't work in official GitHub Actions.

env is not available in jobs.*.if, the bad case to check this is not implemented in act.

The second option actually completely incorrectly evaluates to true…

In my opinon that they evaluate to true is correct, because this matches a well known bug in GitHub Actions Job If and act is expected you to help to detect that locally.
If you tell me that GitHub fixed that bug together with a reproducable workflow, then yes act should follow the fix of GitHub Actions.

Hey @ChristopherHX! Thanks for the quick feedback and insights!

Ha! I rely too much on act lately to avoid testing it on GitHub… πŸ₯²

In case anyone else stumbles upon this, see context availability docs.

P.S. env context is available inside jobs.<job_id>.steps.if. I guess a good workaround for jobs.<job_id>.if is to use an earlier job output.

@ChristopherHX on the same note, does act performs any workflow file validation? I was going to suggest using rhysd/actionlint, but looks like it's already in dependencies. But act hasn't failed the workflow file validation when I ran it, like GitHub does, or like actionlint does in their playground which matches GitHub. Would be fantastic to have that behavior out of the box?

rhysd/actionlint, but looks like it's already in dependencies

Expression parsing logic is used by act from actionlint. The rest is still completly independent.

For example act might run workflows, actionlint would complain about if actionlint is right or not depends on the used functionality.

The best linter is the official GitHub Actions Vscode extension, because it uses a ts port of the exact same parser used by the GitHub Actions Service.
It also autocompletes your expressions.

Sorry, but nektos/act is not my own project, e.g. I depend on other peoples approval to do anything here
Lately I'm struggeling to get two reviews in an acceptable time (within 30days) for new features in act, while the old review requirements are still intact. I'm currently avoiding starting new features, bejond these which still await reviews since a couple of months, to avoid investing work in potenteally abandoned features due to missing reviewers