act icon indicating copy to clipboard operation
act copied to clipboard

Can't access to input variables on 'workflow_dispatch' event

Open matiasalbarello opened this issue 5 years ago • 5 comments

I have this action:

name: Simple Task

on:
  workflow_dispatch:
    inputs:
      delay_seconds:
        description: 'Time to delay'
        required: false
        default: 60

jobs:
  simple-task:
    runs-on: ubuntu-latest

    steps:
      - name: delay execution
        env:
          input_delay: ${{ github.event.inputs.delay_seconds }}
        run: sleep $input_delay

      - name: Run a one-line script
        run: echo 'done'

When executing act workflow_dispatch -j simple-task I get the following error: ERRO[0000] Unable to interpolate string '${{ github.event.inputs.delay_seconds }}' - [TypeError: Cannot access member 'delay_seconds' of undefined]

The workflow works fine on github.

matiasalbarello avatar Jan 19 '21 16:01 matiasalbarello

Looks like same as https://github.com/nektos/act/issues/295

pauliusm avatar Jan 22 '21 16:01 pauliusm

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

github-actions[bot] avatar Feb 22 '21 00:02 github-actions[bot]

Any workaround for this?

I've tried adding a JSON payload like this

{
  "workflow_dispatch": {
    "inputs": {
      "IMAGE_TAG": "dev-1"
    }
  }
}

It doesn't work

benc-uk avatar Mar 23 '21 11:03 benc-uk

Ahhh got it working with simply

{
  "inputs": {
    "IMAGE_TAG": "latest"
  }
}

The docs/README are a little unclear on how to format the JSON, it's implied from the provided example, that the top level keys are the event types, but this isnt the case

benc-uk avatar Mar 23 '21 18:03 benc-uk

@benc-uk Thanks for your comment and I agree with you. This should be either fixed to work like other events or this exception should be clearly stated in README because this behaviour wasn't inferable for me by reading https://github.com/nektos/act#events

ryuheechul avatar Jul 02 '21 09:07 ryuheechul