Show Menu
Cheatography

Github Contexts & Default Environment Variables Cheat Sheet (DRAFT) by

A Github Contexts Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Context Overview

Context Name
Descri­ption
github
Inform­ation about the workflow run
env
Enviro­nment variables set in a workflow, job, or step
job
Inform­ation about the currently executing job
steps
Inform­ation about the steps that have been run in this job
runner
Inform­ation about the runner that is running the current job
secrets
Enables access to secrets
strategy
Enables access to the configured strategy parameters and inform­ation about the current job. Strategy parameters include fail-fast, job-index, job-total, and max-pa­rallel
matrix
Enables access to the matrix parameters you configured for the current job. For example, if you configure a matrix build with the os and node versions, the matrix context object includes the os and node versions of the current job
needs
Enables access to the outputs of all jobs that are defined as a dependency of the current job
inputs
Enables access to the inputs of reusable workflow
 

Access context inform­ation

Index syntax:
Example: github­['sha']
Property derefe­rence syntax:
Example: github.sha
Note that in order to use property derefe­rence syntax, property name must:
--> Start with
a-Z
or
_
--> Be followed by
a-Z
,
0-9
or
_
 

Default Enviro­nment Variables

Enviro­nment Variable
Descri­ption
CI
Always
true
GITHUB­_WO­RKFLOW
Name of the workflow
GITHUB­_RUN_ID
Unique number for each run within a reposi­tory. This number does not change if you re-run the workflow run.
GITHUB­_RU­N_N­UMBER
Unique number for each run of a particular workflow in a reposi­tory. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run.
GITHUB_JOB
The job_id of the current job
GITHUB­_ACTION
Unique identifier (id) of the action
GITHUB­_AC­TIO­N_PATH
The path where your action is located. You can use this path to access files located in the same repository as your action. This variable is only supported in composite actions
GITHUB­_AC­TIONS
Always set to
true
when GitHub Actions is running the workflow. You can use this variable to differ­entiate when tests are being run locally or by GitHub Actions
GITHUB­_ACTOR
The name of the person or app that initiated the workflow
GITHUB­_RE­POS­ITORY
The owner and repository name
GITHUB­_EV­ENT­_NAME
The name of the webhook event that triggered the workflow
GITHUB­_EV­ENT­_PATH
The path of the file with the complete webhook event payload
GITHUB­_WO­RKSPACE
The GitHub workspace directory path, initially empty. For example, /home/­run­ner­/wo­rk/­my-­rep­o-n­ame­/my­-re­po-­name. The action­s/c­heckout action will check out files, by default a copy of your reposi­tory, within this directory
GITHUB_SHA
The commit SHA that triggered the workflow
GITHUB_REF
The branch or tag ref that triggered the workflow. For example, refs/h­ead­s/f­eat­ure­-br­anch-1. If neither a branch or tag is available for the event type, the variable will not exist
GITHUB­_RE­F_NAME
The branch or tag name that triggered the workflow ru
GITHUB­_RE­F_P­ROT­ECTED
true
if branch protec­tions are configured for the ref that triggered the workflow run
GITHUB­_RE­F_TYPE
The type of ref that triggered the workflow run. Valid values are
branch
or
tag
GITHUB­_HE­AD_REF
Only set for pull request events. The name of the head branch
GITHUB­_BA­SE_REF
Only set for pull request events. The name of the base branch
GITHUB­_SE­RVE­R_URL
Returns the URL of the GitHub server. For example:
https:­//g­ith­ub.com
GITHUB­_AP­I_URL
Returns the API URL. For example:
https:­//a­pi.g­it­hub.com
GITHUB­_GR­APH­QL_URL
Returns the GraphQL API URL. For example:
https:­//a­pi.g­it­hub.co­m/g­raphql
RUNNER­_NAME
The name of the runner executing the job
RUNNER_OS
The operating system of the runner executing the job. Possible values are
Linux
,
Windows
, or
macOS
RUNNER­_ARCH
The archit­ecture of the runner executing the job. Possible values are
X86
,
X64
,
ARM
, and
ARM64
RUNNER­_TEMP
The path to a temporary directory on the runner. This directory is emptied at the beginning and end of each job. Note that files will not be removed if the runner's user account does not have permission to delete them.
RUNNER­_TO­OL_­CACHE
The path to the directory containing preins­talled tools for GitHub­-hosted runners