1
0
mirror of synced 2026-01-05 03:06:35 -05:00
Files
docs/data/reusables/actions/actions-vars-context-example-usage.md
Joe Clark 471701851f Add documentation for GitHub Actions configuration variables (#33119)
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tauhid Anjum <tauhidanjum@gmail.com>
Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2023-01-10 05:17:34 +00:00

37 lines
1.3 KiB
Markdown

If a configuration variable has not been set, the return value of an context referencing the variable will be an empty string.
The following examples shows using configuration variables with the `vars` context across a workflow. Each of the following configuration variables have been defined at the repository, organization, or environment levels.
{% raw %}
```yaml
on:
workflow_dispatch:
env:
# Setting an environment variable with the value of a configuration variable
env_var: ${{ vars.ENV_CONTEXT_VAR }}
jobs:
display-variables:
name: ${{ vars.JOB_NAME }}
# You can use configuration variables with the `vars` context for dynamic jobs
if: ${{ vars.USE_VARIABLES == 'true' }}
runs-on: ${{ vars.RUNNER }}
environment: ${{ vars.ENVIRONMENT_STAGE }}
steps:
- name: Use variables
run: |
echo "repository variable : ${{ vars.REPOSITORY_VAR }}"
echo "organization variable : ${{ vars.ORGANIZATION_VAR }}"
echo "overridden variable : ${{ vars.OVERRIDE_VAR }}"
echo "variable from shell environment : $env_var"
- name: ${{ vars.HELLO_WORLD_STEP }}
if: ${{ vars.HELLO_WORLD_ENABLED == 'true' }}
uses: actions/hello-world-javascript-action@main
with:
who-to-greet: ${{ vars.GREET_NAME }}
```
{% endraw %}