Skip to the content.

Setting An Environment Variable

Environment Variables can be specified in the following format:

echo "{environment_variable_name}={value}" >> $GITHUB_ENV

Example

steps:
    - name: Setting the environment variable
    run: |
        echo "GIT_VERSION=$(git --version)" >> $GITHUB_ENV

    - name: Check Git version
    run: |
        echo "${GIT_VERSION}"

Note: Can also use $ format to get the environment variable value.

Source: StackOverFlow