env key
The workflow key that sets environment variables for every step of a workflow, a job, or a single step.
In more detail
Setting a value on the step that needs it keeps it out of every other step. Passing event data and secrets through env, rather than writing an expression straight into a shell command, also avoids script injection.
Example
env:
API_TOKEN: ${{ secrets.API_TOKEN }}Related terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- secret — Any value that grants access, such as a password, access token or private key, and must be kept out of code and version control.
- workflow expression — Text inside ${{ and }} in a workflow file that GitHub evaluates before a step runs, such as ${{ github.sha }}.
Taught in
- Triggers and the Event Model — Continuous Integration & Continuous Delivery Pipelines
- Securing Pipelines: Secrets Management — Continuous Integration & Continuous Delivery Pipelines
- The Workflow That Ran On A Stranger's Pull Request — GitHub Actions (GH-200) Exam Prep
- Triggers In Depth: Filters, Schedules And Dispatch — GitHub Actions (GH-200) Exam Prep
- Workflow Structure: Jobs, Env, Services, Commands And Anchors — GitHub Actions (GH-200) Exam Prep
- Expressions, Contexts And The If That Is Always True — GitHub Actions (GH-200) Exam Prep
- Reusable Workflows: Inputs, Secrets And Outputs Across A Call — GitHub Actions (GH-200) Exam Prep
- Outputs, Artifacts, Caches And Job Summaries — GitHub Actions (GH-200) Exam Prep
- Why It Ran, Why It Did Not: Reading Runs, Jobs And Checks — GitHub Actions (GH-200) Exam Prep
- Three Kinds Of Action: JavaScript, Docker Container Or Composite — GitHub Actions (GH-200) Exam Prep
- action.yml: Inputs, Outputs, Runs And Branding — GitHub Actions (GH-200) Exam Prep
- Building And Debugging A JavaScript Action — GitHub Actions (GH-200) Exam Prep
- Secrets And Variables By Scope: Precedence, Access And The REST API — GitHub Actions (GH-200) Exam Prep
- Environments: Reviewers, Wait Timers And Deployment Rules — GitHub Actions (GH-200) Exam Prep
- Script Injection: When An Issue Title Becomes Code — GitHub Actions (GH-200) Exam Prep
- YAML-Reading Sprint: What Happens When This Runs? — GitHub Actions (GH-200) Exam Prep