GitHub sets default environment variables that are available to every step in a workflow run. Environment variables are case-sensitive. Commands run in actions or steps can create, read, and modify environment variables.
To set custom environment variables, you need to specify the variables in the workflow file. You can define environment variables for a step, job, or entire workflow using the
env keywords. For more information, see "Workflow syntax for GitHub."
steps: - name: Hello world run: echo Hello world $FIRST_NAME $middle_name $Last_Name! env: FIRST_NAME: Mona middle_name: The Last_Name: Octocat
You can also use the
GITHUB_ENV environment file to set an environment variable that the following steps in a workflow can use. The environment file can be used directly by an action or as a shell command in a workflow file using the
run keyword. For more information, see "Workflow commands for GitHub Actions."
We strongly recommend that actions use environment variables to access the filesystem rather than using hardcoded file paths. GitHub sets environment variables for actions to use in all runner environments.
|Always set to |
|The path to the GitHub home directory used to store user data. For example, |
|The name of the workflow.|
|A unique number for each run within a repository. This number does not change if you re-run the workflow run.|
|A unique number for each run of a particular workflow in a repository. 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.|
|The unique identifier (|
|Always set to |
|The name of the person or app that initiated the workflow. For example, |
|The owner and repository name. For example, |
|The name of the webhook event that triggered the workflow.|
|The path of the file with the complete webhook event payload. For example, |
|The GitHub workspace directory path. The workspace directory is a copy of your repository if your workflow uses the actions/checkout action. If you don't use the |
|The commit SHA that triggered the workflow. For example, |
|The branch or tag ref that triggered the workflow. For example, |
|Only set for forked repositories. The branch of the head repository.|
|Only set for forked repositories. The branch of the base repository.|
|Returns the URL of the GitHub server. For example: |
|Returns the API URL. For example: |
|Returns the GraphQL API URL. For example: |
Note: GitHub reserves the
GITHUB_ environment variable prefix for internal use by GitHub. Setting an environment variable or secret with the
GITHUB_ prefix will result in an error.
Any new environment variables you set that point to a location on the filesystem should have a
_PATH suffix. The
GITHUB_WORKSPACE default variables are exceptions to this convention because the words "home" and "workspace" already imply a location.