I’m running into an issue I’m hoping someone else can help shed some light on. I want to be able to run a github action only for deployment events that have a matching key in the deployment payload (encoded as json – taken from https://docs.github.com/en/rest/reference/repos#create-a-deployment--parameters).
The following works and prints out true
when run:
on:
- deployment
jobs:
do_something:
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- run: |
echo "The deployment key is: ${{ fromJSON(github.event.deployment.payload).someKey == 'expectedValue' }}"
However, if I try using this in jobs.if
it throws an error when run (GitHub Actions has encountered an internal error when running your job.
):
on:
- deployment
jobs:
do_something:
timeout-minutes: 1
runs-on: ubuntu-latest
if: fromJSON(github.event.deployment.payload).someKey == 'expectedValue'
steps:
- run: |
echo "The deployment key is: ${{ fromJSON(github.event.deployment.payload).someKey == 'expectedValue' }}"
It would seem to me that the above should work. Out of curiosity I did try running using the contains
function and it worked as expected (very hacky though).
on:
- deployment
jobs:
do_something:
timeout-minutes: 1
runs-on: ubuntu-latest
if: contains(github.event.deployment.payload,'expectedValue')
steps:
- run: |
echo "The deployment key is: ${{ fromJSON(github.event.deployment.payload).someKey == 'expectedValue' }}"
Any ideas would be greatly appreciated!