How to Define Variables for an Automation Script

2.4.5. How to Define Variables for an Automation Script#

GitHub allows the use of variables in Workflows definitions and provides a variety of context variables that can be accessed using the ${{...}} syntax.

Some important contextual variables include:

  • github: Provides metadata about the Workflow run, Repository, and event that triggered the Workflow, etc.

    • E.g. github.event_name indicates the name of the event that triggered the Workflow (e.g. push, pull_request, etc.) while github.repository provides the name of the Repository.

  • vars: Contains variables defined at the Repository, Organization or Environment level. These variables can be set via the Web-UI.

    • For instance, vars.my_variable represents a variable named my_variable.

Warning

Sensitive data should be stored outside of GitHub! secrets is the only half-way acceptable place to store sensitive data!

  • secrets: contains the names and values of secrets defined for the Repository, Organization or Environment. Secrets are handled in a specific way by GitHub and can be set via the Web-UI.

    • For example, secrets.TOKEN refers to a secret named TOKEN.