Home > Blockchain >  Simple echo of github.event fails in Github Actions
Simple echo of github.event fails in Github Actions

Time:12-10

I just want to print out the github.event context in a GitHub Actions step, so I am doing the following

      - name: check context
        shell: bash
        run: echo ${{ toJSON(github.event) }}

However this fails as follows:

/home/runner/work/_temp/hd73999-5309-44cf-9218-9e2e3805d525.sh: line 2: after:: command not found
Error: Process completed with exit code 127.

(although the github.event DOES get printed before the error.

Why is that?

I am using the toJSON function because if I don't all that gets printed is:

Run echo Object
Object

CodePudding user response:

You need to add quotes around the expression so it doesn't evaluate it as JS.

From: https://docs.github.com/en/actions/learn-github-actions/contexts#example-printing-context-information-to-the-log

name: Context testing
on: push

jobs:
  dump_contexts_to_log:
    runs-on: ubuntu-latest
    steps:
      - name: Dump GitHub context
        id: github_context_step
        run: echo '${{ toJSON(github) }}'
  • Related