Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GitHub actions inputs don't get printed with echo

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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!

>Solution :

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 }}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading