Home > Enterprise >  GitHub actions inputs don't get printed with echo
GitHub actions inputs don't get printed with echo

Time:01-22

I've been trying to set up the most basic GitHub action that can be triggered via API, and I managed to trigger it, but now I'm having trouble passing down the "inputs" and using them in the jobs... I tried reading the documentation and all, and it should work but I'm probably missing some syntax or something... Here's the action code:

name: Test

on:
  repository_dispatch:
    inputs:
      body:
        default: 'testdefaultvalue'
        description: 'Test desc'
        required: true
        
        
jobs:
  print_inputs:
    runs-on: ubuntu-latest
    steps:
    - name: Print inputs
      run: echo "The inputs are ${{ inputs.body }}"

And here's the body that I'm trying to send using POST which hits and triggers this action

{"event_type": "my_event", "client_payload": {"body": "Hello, world!"}} 

I keep getting only the first part of the echo, like on this screenshot enter image description here

I even tried just printing out the inputs body with the default value using a different kinds of syntaxes but nothing worked. Hopefully, this is not a duplicate and someone will help me and it'll be useful for someone in the future as well!

CodePudding user response:

According to repository_dispatch, you need to refer to the complete event context to get the values.

So, this should work in your case:

echo ${{ github.event.client_payload.body }}
  • Related