I have a test job that is supposed to be triggered in one of three ways: Automatically on Pull Request, manually by workflow dispatch, and automatically by a separate job that uses repository dispatch.*
Both workflow dispatch and repository dispatch should carry the same input information, while automatic pull request triggers don’t carry any input information at all. But the workflow dispatch has the input in the context github.events.input
while repository dispatch has it at github.events.client_payload
.
I tried and failed to coalesce these values into environment variables with bash:
echo "foo=${${{ github.event.client_payload.foo }}:-${{ github.event.input.foo }}:-default}" >> $GITHUB_ENV
This returns an error for bad substitution. I’m not entirely sure what that means, and can’t find much pertinent information, but it seems that bash coalescence is intended to be run on variables, not values.
Maybe I misunderstood the above error, but the more general question is:
Is there a viable best practice to handle these different input sources and funnel whichever one applies into my final config? And is there a way to also handle default values in case of pull requests?