Skip to content

Commit

Permalink
add vars to global contexts (fix #259)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jan 18, 2023
1 parent 837e713 commit 576fd99
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions expr_sema.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ var BuiltinGlobalVariableTypes = map[string]ExprType{
// https://docs.github.com/en/actions/learn-github-actions/contexts#inputs-context
// https://docs.github.com/en/actions/learn-github-actions/reusing-workflows
"inputs": NewEmptyStrictObjectType(),
// https://docs.github.com/en/actions/learn-github-actions/contexts#vars-context
"vars": NewMapObjectType(StringType{}), // vars.<var_name>
}

// Semantics checker
Expand Down
26 changes: 26 additions & 0 deletions testdata/ok/variables.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 }}

0 comments on commit 576fd99

Please sign in to comment.