act icon indicating copy to clipboard operation
act copied to clipboard

`if` condition in composite action misbehaves with `uses`

Open novascreen opened this issue 6 months ago • 1 comments

Bug report info

act version:            0.2.65
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 10
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        $HOME/.docker/run/docker.sock
Config files:           
        /Users/.../Library/Application Support/act/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
        .actrc:
                --container-architecture=linux/amd64
                --container-daemon-socket -
                -P arc-rs-dind=catthehacker/ubuntu:act-latest
Build info:
        Go version:            go1.22.5
        Module path:           command-line-arguments
        Main version:          
        Main path:             
        Main checksum:         
        Build settings:
                -buildmode:           exe
                -compiler:            gc
                -ldflags:             -X main.version=0.2.65
                DefaultGODEBUG:       httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
                CGO_ENABLED:          1
                CGO_CFLAGS:           
                CGO_CPPFLAGS:         
                CGO_CXXFLAGS:         
                CGO_LDFLAGS:          
                GOARCH:               arm64
                GOOS:                 darwin

Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Command used with act

act pull_request -v \
  -e .act/event.json \
  -W .github/workflows/test-workflow.yml

Describe issue

I'm passing a secret as an input to a composite action. In the composite action I want to run a third party action with uses based on whether the input is defined or not.

When I use an if condition on a shell step it works correctly, however on the step that uses the third party action the expression is suddenly evaluated to false.

Link to GitHub repository

No response

Workflow content

name: Test Workflow

on:
  pull_request:

jobs:
  test-job:
    runs-on: ubuntu-latest
    steps:
      - if: ${{ secrets.TEST_SECRET == '' }}
        run: echo "Secret undefined"

      - if: ${{ secrets.TEST_SECRET != '' }}
        run: echo "Secret defined"

      - uses: actions/checkout@v4

      - uses: ./.github/actions/composite-test
        with:
          test-input: ${{ secrets.TEST_SECRET }}


# Composite action

name: Composite test

inputs:
  test-input:
    description: 'My test input'
    required: false
    default: ''

runs:
  using: 'composite'
  steps:
    - name: 'Bash, input undefined'
      if: inputs.test-input == ''
      shell: bash
      run: echo "test-input defined"
    - name: 'Bash, input defined'
      if: inputs.test-input != ''
      shell: bash
      run: echo "test-input defined"
    - name: 'Action, input defined'
      if: inputs.test-input != ''
      uses: actions/checkout@v4

Relevant log output

[Test Workflow/test-job] [DEBUG] evaluating expression '${{ ***s.TEST_SECRET == '' }}'
[Test Workflow/test-job] [DEBUG] expression '${{ ***s.TEST_SECRET == '' }}' evaluated to 'false'
[Test Workflow/test-job] [DEBUG] Skipping step 'echo "Secret undefined"' due to '${{ ***s.TEST_SECRET == '' }}'
...
[Test Workflow/test-job] [DEBUG] evaluating expression '${{ ***s.TEST_SECRET != '' }}'
[Test Workflow/test-job] [DEBUG] expression '${{ ***s.TEST_SECRET != '' }}' evaluated to 'true'
[Test Workflow/test-job] ⭐ Run Main echo "Secret defined"
...
[Test Workflow/test-job] [DEBUG] Wrote command 

echo "Secret defined"

 to 'workflow/1'
...
| Secret defined
[Test Workflow/test-job]   ✅  Success - Main echo "Secret defined"
...
[Test Workflow/test-job] ⭐ Run Main actions/checkout@v4
...
[Test Workflow/test-job]   ✅  Success - Main actions/checkout@v4
...
[Test Workflow/test-job] [DEBUG] expression '${{ ***s.TEST_SECRET }}' rewritten to 'format('{0}', ***s.TEST_SECRET)'
[Test Workflow/test-job] [DEBUG] evaluating expression 'format('{0}', ***s.TEST_SECRET)'
[Test Workflow/test-job] [DEBUG] expression 'format('{0}', ***s.TEST_SECRET)' evaluated to '%!t(string=***)'
...
[Test Workflow/test-job] ⭐ Run Main ./.github/actions/composite-test
...
[Test Workflow/test-job] [DEBUG] evaluating expression 'inputs.test-input == '''
[Test Workflow/test-job] [DEBUG] expression 'inputs.test-input == ''' evaluated to 'false'
[Test Workflow/test-job] [DEBUG] Skipping step 'Bash, input undefined' due to 'inputs.test-input == '''
...
[Test Workflow/test-job] [DEBUG] evaluating expression 'inputs.test-input != '''
[Test Workflow/test-job] [DEBUG] expression 'inputs.test-input != ''' evaluated to 'true'
[Test Workflow/test-job] ⭐ Run Main Bash, input defined
...
[Test Workflow/test-job] [DEBUG] Wrote command 

echo "test-input defined"

 to 'workflow/3-composite-1.sh'
...
| test-input defined
[Test Workflow/test-job]   ✅  Success - Main Bash, input defined
...
[Test Workflow/test-job] [DEBUG] evaluating expression 'inputs.test-input != '''
[Test Workflow/test-job] [DEBUG] expression 'inputs.test-input != ''' evaluated to 'false'
[Test Workflow/test-job] [DEBUG] Skipping step 'Action, input defined' due to 'inputs.test-input != '''
[Test Workflow/test-job] [DEBUG] Found revision: 7cc4b33435c8f25415bd4e1644374780f0c50e00
[Test Workflow/test-job]   ✅  Success - Main ./.github/actions/composite-test
...

Additional information

My event.json only has base and head refs defined, nothing else.

novascreen avatar Aug 17 '24 21:08 novascreen