Open novascreen opened 1 month ago
I have the same issue and the only condition that seems work is testing for null
if: ! inputs.test-input
I have a similar issue.
This works as expected, and prints out "Works! And this says 'true': true"
- name: Shell command
if: ${{ (fromJSON(inputs.myinput) == true }}
shell: bash
run: echo "Works! And this says 'true': ${{ fromJSON(inputs. inputs.myinput) }}"
However, this next one one errors out:
- name: Run another action
if: ${{ fromJSON(inputs.myinput) == true }}
uses: myrepo/myaction@main
Error in if-expression: "if: ${{ (fromJSON(inputs.myinput) == true }}" (Cannot parse non-string type invalid as JSON).
My guess is that somehow the input is being forgotten, returning a null object or something that causes fromJSON()
to choke on a non-existing value.
Regression of https://github.com/nektos/act/pull/2348?
Missing / unreliable tests of the code
I'm seeing the same behavior. My team makes heavy use of composite actions and being able to use this tool would have a significant impact for us.
Regression of https://github.com/nektos/act/pull/2348?
@ChristopherHX Correct me if I'm wrong, but I believe the tests added in that PR won't detect an issue like this because the problem only surfaces when an if
condition which uses inputs passed to the current composite action is being used, and the actions added in the testdata dir do not set such a condition.
I meant this bug might has been caused by #2348.
It doesn't read like we have the same impression what I meant.
So a first step to see if reverting that specifc commit works and run go build to get a binary, then verify if my assumption is correct.
Next steps would be to either propose a revert of #2348 and rerelease act or figure out to solve both the defect that PR aimed to fix and this one.
My team makes heavy use of composite actions and being able to use this tool would have a significant impact for us.
Downgrading act to a version (GitHub shows tags including the merged commit, just use the one lower) without that change is a temporary consumer solution
I don't expect any resolution this month, my focus is on different projects.
This is on my backlog, my work for act cli is currently slow
Confirmed as Regression due to mergin #2348
name: "Test Composite Action"
description: "Test action uses composite"
inputs:
b:
default: true
b2: {}
runs:
using: "composite"
steps:
- uses: actions/github-script@v7
if: inputs.b == 'true'
with:
script: |
console.log(${{ tojson(inputs) }})
if( ${{ tojson(inputs.b) }} != 'true' ) {
process.exit(-1);
}
github-token: noop
- uses: actions/github-script@v7
if: inputs.b != 'true'
with:
script: |
console.log(${{ tojson(inputs) }})
if( ${{ tojson(inputs.b) }} == 'true' ) {
process.exit(-1);
}
github-token: noop
- uses: actions/github-script@v7
if: inputs.b2 == 'false'
with:
script: |
console.log(${{ tojson(inputs) }})
if( ${{ tojson(inputs.b2) }} != 'false' ) {
process.exit(-1);
}
github-token: noop
- uses: actions/github-script@v7
if: inputs.b2 != 'false'
with:
script: |
console.log(${{ tojson(inputs) }})
if( ${{ tojson(inputs.b2) }} == 'false' ) {
process.exit(-1);
}
github-token: noop
called by
name: uses-composite-check-for-input-in-if-uses
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./uses-composite-check-for-input-in-if-uses/composite_action
with:
b: true
b2: true
- uses: ./uses-composite-check-for-input-in-if-uses/composite_action
with:
b: false
b2: false
- uses: ./uses-composite-check-for-input-in-if-uses/composite_action
with:
b: true
b2: false
- uses: ./uses-composite-check-for-input-in-if-uses/composite_action
with:
b: false
b2: true
I'm working on a fix right now, highest priority issue for act in my backlog.
Issues filed as defects of github-act-runner are processed and merged faster.
E.g. git revert b5ad3c4acd89cc8a7d1ce8bdb41c16d48b2cdf36 && go build
on current master gives you are more recent act binary without this specfic defect
Help wanted to verify: https://github.com/nektos/act/pull/2473, awaiting review this can take unspecified amount of time
Portable Binaries are in CI-Checks Artifacts of that PR, since act is all about GitHub Actions this should be self explaining.
Bug report info
Command used with act
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 thatuses
the third party action the expression is suddenly evaluated tofalse
.Link to GitHub repository
No response
Workflow content
Relevant log output
Additional information
My
event.json
only has base and head refs defined, nothing else.