Cookbook
These are some additional recipes you can implement in Github Actions!
Debugging Github Actions
Given that steps in a job can be a script, you can actually perform logging as steps in a job:
These will add a step to the job that logs these echos.
Conditional steps
You can also run steps based on certain conditions (using expressions). This is particularly useful when you want to only run a step when certain conditions are met.
The above step only runs when the runner OS is Windows.
Adding environment variables
Given that virtual machine runners run an OS, you will have access to environment variables from within the job through the env
context. To add to the env
context, you can use a step:
The above exports a new environment variable START
into env
. This can be then accessed via ${{ env.START }}
.
Matrix strategies
Suppose that you want to verify that a set of changes are not susceptible to backward compatibility issues in a Node.js environment (version 20
), while ensuring that the latest Node.js version is supported as well (version 23
).
You can actually use matrix strategies to verify this information by running the same job across different parameters.
So using the above, we are able to then run the same job example_matrix
twice with two different node versions: 20
and 23
.
Last updated