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.
More on Contexts, Expressions, Env & Outputs
List the available contexts and what each holds.BeginnerWhich contexts can you use in which keys? Give two examples that trip people up.AdvancedWhat are the expression operators and how do comparisons coerce types?IntermediateHow do you write a ternary in GitHub Actions expressions?IntermediateWhat do `contains`, `startsWith`, `endsWith`, `format` and `join` do?BeginnerWhat are object filters (`.*`) and how are they useful?Intermediate