In GitHub Actions, you can define custom environment variables for a specific step using the env keyword. Here's an example:
name: Demo workflow
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run a step with custom environment variables
run: |
echo "Custom Variable 1: $CUSTOM_VAR_1"
echo "Custom Variable 2: $CUSTOM_VAR_2"
env:
CUSTOM_VAR_1: This is the first custom variable
CUSTOM_VAR_2: This is the second custom variable
In this workflow, the "Run a step with custom environment variables" step has two custom environment variables: CUSTOM_VAR_1 and CUSTOM_VAR_2. These variables are defined using the env keyword, and their values are set to "This is the first custom variable" and "This is the second custom variable", respectively.
The run command is a multi-line command. Each line is a separate command that prints the name and value of a custom environment variable. The $ symbol is used to reference the value of an environment variable.
This workflow will run whenever a push or pull request event occurs. The output of the "Run a step with custom environment variables" step can be viewed in the logs for the workflow run.
In GitHub Actions, you can define custom environment variables for a specific step using the
env
keyword. Here's an example:In this workflow, the "Run a step with custom environment variables" step has two custom environment variables:
CUSTOM_VAR_1
andCUSTOM_VAR_2
. These variables are defined using theenv
keyword, and their values are set to "This is the first custom variable" and "This is the second custom variable", respectively.The
run
command is a multi-line command. Each line is a separate command that prints the name and value of a custom environment variable. The$
symbol is used to reference the value of an environment variable.This workflow will run whenever a push or pull request event occurs. The output of the "Run a step with custom environment variables" step can be viewed in the logs for the workflow run.