GitHub Actions allows maintainers to require that a workflow job meet certain criteria before running. For example, they may require that a job get explicit approval from two specific maintainers before running, guarantee the job only runs on specific branches or after a minimal time delay, etc.
Unfortunately, they gave this feature a (imo) terrible name: “environments”.
A workflow job is set to run in a specific environment by setting its environment:
variable:
jobs:
deploy:
environment: production # requires approval by @foo and @bar
steps:
- ...
My question is: is there a workflow variable that can be used at runtime to inspect the environment’s requirements, or at least its name? Something like ${{ github.environment }}
or something?
I’ve seen there’s a REST API endpoint to get the environment’s description given a name, but I haven’t found a way to identify the environment’s name in the first place (other than checking out the repository and inspecting the workflow file itself, which seems like overkill).