How to send webhook client_payload received in GitHub Actions workflow via repository_dispatch to a python script

Viewed 14

I have configured a repository_dispatch event in GitHub Actions to catch a webhook and would like to send the client_payload to a Python script for processing.

If I do run: echo ${{ github.event.client_payload }} in the workflow, the json prints to screen as expected.

However, if I pass ${{ github.event.client_payload }} as a parameter to a python script with:

run: python myscript.py -d ${{ github.event.client_payload }}

it does not pass the object, it instead passes the string "Object"

How can I pass the actual object?

The individual attributes of the object are able to pass, I guess I could manually re-construct the object with something like:

-d '{"key":${{ github.event.client_payload.somevalue }}}'

Or I could write it out to a json file with echo, then read the file from my script, any better ways?

1 Answers

Aww dang, I just realized searching back through commits, back when I had the echo printing the correct output I was using: run: echo ${{ toJson(github.event.client_payload }}

As soon as I changed the python parameter to use toJson it worked:

run: python myscript.py -d ${{ toJson(github.event.client_payload) }}
Related