Dump Context Action
This week's Action Spotlight introduces a new kind of action. It's the first time we're featuring a composite action, which allows you to include multiple workflow steps as a single
What does it do?
This action outputs the following items from the runner environment:
This allows you to see things like
github.event in the output to debug the data available to your actions.
How does it work?
This is a composite action, which means that the whole thing is in a single
action.yml file. It contains the fields that we'd expect to see, such as
branding. However, it also has a value that we've not seen before;
This tells Actions that the action provides steps that should be run as though they were provided in the workflow itself.
There are seven steps, each dumping a different aspect of the environment. Each step uses the
toJson function to convert the input to a string that can be rendered in the output and stores that in the environment. Storing it in the environment prevents quoting issues when echoing out the value later.
The characters before each heading (e.g.
\033[31;1;4m) are ANSI escape codes, which tells the output to make that text red, bold and underlined.
Finally, each step has the shell set to
bash. This makes the action usable on all operating systems. Without this, the action would default to Powershell on Windows and fail.
That's all there is to it - seven steps, all following the same pattern to output useful data in the logs.
Common use cases
There's only one use case - dump the current context to for debugging purposes:
name: Dump Contexton: [push, pull_request]jobs:dump:runs-on: ubuntu-lateststeps:- name: Dump contextuses: crazy-max/[email protected]