Skip to content
name: Example Workflow
on: [push]
jobs:
set_env_var:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set Environment Variable
id: set-env
run: |
echo "MY_ENV_VAR=HelloWorld" >> $GITHUB_OUTPUT
outputs:
my_env_var: ${{ steps.set-env.outputs.MY_ENV_VAR }}
example_job:
runs-on: ubuntu-latest
needs:
[
set_env_var,
]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Get Environment Variable
run: echo "The value of MY_ENV_VAR is ${{ needs.set_env_var.outputs.my_env_var }}"
- name: Use Environment Variable in Another Step
run: |
if [[ "${{ needs.set_env_var.outputs.my_env_var }}" == "HelloWorld" ]]; then
echo "The environment variable is correctly set!"
else
echo "The environment variable is not set correctly."
fi