Interview Prep/GitHub Actions/Contexts, Expressions, Env & Outputs

How do you dump all contexts for debugging without breaking the shell?

BeginnerConceptContexts, Expressions, Env & Outputs
Answer

Pass them through environment variables, never inline into the script:

- name: Dump contexts
  env:
    GITHUB_CONTEXT: ${{ toJSON(github) }}
    NEEDS_CONTEXT: ${{ toJSON(needs) }}
  run: |
    echo "$GITHUB_CONTEXT" | jq '{event_name, ref, sha, actor}'
    echo "$NEEDS_CONTEXT"

The github context contains the token, but it is masked; still, remove such steps after debugging.

All GitHub Actions questions Roadmap: GitHub Actions

More on Contexts, Expressions, Env & Outputs