home / tils / til

Menu
  • GraphQL API

til: github-actions_dump-context.md

This data as json

path topic title url body html shot created created_utc updated updated_utc shot_hash slug
github-actions_dump-context.md github-actions Dump out all GitHub Actions context https://github.com/simonw/til/blob/main/github-actions/dump-context.md Useful for seeing what's available for `if: ` conditions (see [context and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions)). I copied this example action [from here](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#example-printing-context-information-to-the-log-file) and deployed it [here](https://github.com/simonw/playing-with-actions/blob/master/.github/workflows/dump-context.yml). Here's an [example run](https://github.com/simonw/playing-with-actions/runs/599575180?check_suite_focus=true). ```yaml on: push jobs: one: runs-on: ubuntu-16.04 steps: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - name: Dump job context env: JOB_CONTEXT: ${{ toJson(job) }} run: echo "$JOB_CONTEXT" - name: Dump steps context env: STEPS_CONTEXT: ${{ toJson(steps) }} run: echo "$STEPS_CONTEXT" - name: Dump runner context env: RUNNER_CONTEXT: ${{ toJson(runner) }} run: echo "$RUNNER_CONTEXT" - name: Dump strategy context env: STRATEGY_CONTEXT: ${{ toJson(strategy) }} run: echo "$STRATEGY_CONTEXT" - name: Dump matrix context env: MATRIX_CONTEXT: ${{ toJson(matrix) }} run: echo "$MATRIX_CONTEXT" ``` <p>Useful for seeing what's available for <code>if: </code> conditions (see <a href="https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions">context and expression syntax</a>).</p> <p>I copied this example action <a href="https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#example-printing-context-information-to-the-log-file">from here</a> and deployed it <a href="https://github.com/simonw/playing-with-actions/blob/master/.github/workflows/dump-context.yml">here</a>. Here's an <a href="https://github.com/simonw/playing-with-actions/runs/599575180?check_suite_focus=true">example run</a>.</p> <div class="highlight highlight-source-yaml"><pre><span class="pl-ent">on</span>: <span class="pl-s">push</span> <span class="pl-ent">jobs</span>: <span class="pl-ent">one</span>: <span class="pl-ent">runs-on</span>: <span class="pl-s">ubuntu-16.04</span> <span class="pl-ent">steps</span>: - <span class="pl-ent">name</span>: <span class="pl-s">Dump GitHub context</span> <span class="pl-ent">env</span>: <span class="pl-ent">GITHUB_CONTEXT</span>: <span class="pl-s">${{ toJson(github) }}</span> <span class="pl-ent">run</span>: <span class="pl-s">echo "$GITHUB_CONTEXT"</span> - <span class="pl-ent">name</span>: <span class="pl-s">Dump job context</span> <span class="pl-ent">env</span>: <span class="pl-ent">JOB_CONTEXT</span>: <span class="pl-s">${{ toJson(job) }}</span> <span class="pl-ent">run</span>: <span class="pl-s">echo "$JOB_CONTEXT"</span> - <span class="pl-ent">name</span>: <span class="pl-s">Dump steps context</span> <span class="pl-ent">env</span>: <span class="pl-ent">STEPS_CONTEXT</span>: <span class="pl-s">${{ toJson(steps) }}</span> <span class="pl-ent">run</span>: <span class="pl-s">echo "$STEPS_CONTEXT"</span> - <span class="pl-ent">name</span>: <span class="pl-s">Dump runner context</span> <span class="pl-ent">env</span>: <span class="pl-ent">RUNNER_CONTEXT</span>: <span class="pl-s">${{ toJson(runner) }}</span> <span class="pl-ent">run</span>: <span class="pl-s">echo "$RUNNER_CONTEXT"</span> - <span class="pl-ent">name</span>: <span class="pl-s">Dump strategy context</span> <span class="pl-ent">env</span>: <span class="pl-ent">STRATEGY_CONTEXT</span>: <span class="pl-s">${{ toJson(strategy) }}</span> <span class="pl-ent">run</span>: <span class="pl-s">echo "$STRATEGY_CONTEXT"</span> - <span class="pl-ent">name</span>: <span class="pl-s">Dump matrix context</span> <span class="pl-ent">env</span>: <span class="pl-ent">MATRIX_CONTEXT</span>: <span class="pl-s">${{ toJson(matrix) }}</span> <span class="pl-ent">run</span>: <span class="pl-s">echo "$MATRIX_CONTEXT"</span></pre></div> <Binary: 45,978 bytes> 2020-04-19T07:50:03-07:00 2020-04-19T14:50:03+00:00 2020-04-19T07:50:03-07:00 2020-04-19T14:50:03+00:00 070e1fa70411ed2f9cd92ea28dc399e2 dump-context
Powered by Datasette · How this site works · Code of conduct