зеркало из https://github.com/github/docs.git
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>
This commit is contained in:
Родитель
d27720c729
Коммит
471701851f
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 53 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 48 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 51 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 47 KiB |
|
@ -25,7 +25,7 @@ Some Docker instructions interact with GitHub Actions, and an action's metadata
|
|||
|
||||
### USER
|
||||
|
||||
Docker actions must be run by the default Docker user (root). Do not use the `USER` instruction in your `Dockerfile`, because you won't be able to access the `GITHUB_WORKSPACE`. For more information, see "[Using environment variables](/actions/configuring-and-managing-workflows/using-environment-variables)" and [USER reference](https://docs.docker.com/engine/reference/builder/#user) in the Docker documentation.
|
||||
Docker actions must be run by the default Docker user (root). Do not use the `USER` instruction in your `Dockerfile`, because you won't be able to access the `GITHUB_WORKSPACE`. For more information, see "[Variables](/actions/learn-github-actions/variables#default-environment-variables)" and [USER reference](https://docs.docker.com/engine/reference/builder/#user) in the Docker documentation.
|
||||
|
||||
### FROM
|
||||
|
||||
|
@ -39,7 +39,7 @@ These are some best practices when setting the `FROM` argument:
|
|||
|
||||
### WORKDIR
|
||||
|
||||
{% data variables.product.product_name %} sets the working directory path in the `GITHUB_WORKSPACE` environment variable. It's recommended to not use the `WORKDIR` instruction in your `Dockerfile`. Before the action executes, {% data variables.product.product_name %} will mount the `GITHUB_WORKSPACE` directory on top of anything that was at that location in the Docker image and set `GITHUB_WORKSPACE` as the working directory. For more information, see "[Using environment variables](/actions/configuring-and-managing-workflows/using-environment-variables)" and the [WORKDIR reference](https://docs.docker.com/engine/reference/builder/#workdir) in the Docker documentation.
|
||||
{% data variables.product.product_name %} sets the working directory path in the `GITHUB_WORKSPACE` environment variable. It's recommended to not use the `WORKDIR` instruction in your `Dockerfile`. Before the action executes, {% data variables.product.product_name %} will mount the `GITHUB_WORKSPACE` directory on top of anything that was at that location in the Docker image and set `GITHUB_WORKSPACE` as the working directory. For more information, see "[Variables](/actions/learn-github-actions/variables#default-environment-variables)" and the [WORKDIR reference](https://docs.docker.com/engine/reference/builder/#workdir) in the Docker documentation.
|
||||
|
||||
### ENTRYPOINT
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ The following scripting languages are supported:
|
|||
|
||||
Your custom scripts can use the following features:
|
||||
|
||||
- **Environment variables**: Scripts have access to the default environment variables. The full webhook event payload can be found in `GITHUB_EVENT_PATH`. For more information, see "[Environment variables](/actions/learn-github-actions/environment-variables#default-environment-variables)."
|
||||
- **Variables**: Scripts have access to the default variables. The full webhook event payload can be found in `GITHUB_EVENT_PATH`. For more information, see "[Variables](/actions/learn-github-actions/variables#default-environment-variables)."
|
||||
- **Workflow commands**: Scripts can use workflow commands. For more information, see ["Workflow commands for {% data variables.product.prodname_actions %}"](/actions/using-workflows/workflow-commands-for-github-actions){% ifversion actions-save-state-set-output-envs %}{% else %}, with the exception of `save-state` and `set-output`, which are not supported by these scripts{% endif %}. Scripts can also use environment files. For more information, see [Environment files](/actions/using-workflows/workflow-commands-for-github-actions#environment-files).
|
||||
|
||||
{% note %}
|
||||
|
|
|
@ -24,7 +24,7 @@ featuredLinks:
|
|||
- /actions/learn-github-actions/events-that-trigger-workflows
|
||||
- /actions/learn-github-actions/contexts
|
||||
- /actions/learn-github-actions/expressions
|
||||
- /actions/learn-github-actions/environment-variables
|
||||
- /actions/learn-github-actions/variables
|
||||
- /actions/security-guides/encrypted-secrets
|
||||
changelog:
|
||||
label: actions
|
||||
|
|
|
@ -21,7 +21,7 @@ miniTocMaxHeadingLevel: 3
|
|||
|
||||
## About contexts
|
||||
|
||||
Contexts are a way to access information about workflow runs, runner environments, jobs, and steps. Each context is an object that contains properties, which can be strings or other objects.
|
||||
{% data reusables.actions.actions-contexts-about-description %} Each context is an object that contains properties, which can be strings or other objects.
|
||||
|
||||
{% data reusables.actions.context-contents %} For example, the `matrix` context is only populated for jobs in a [matrix](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix).
|
||||
|
||||
|
@ -36,7 +36,9 @@ You can access contexts using the expression syntax. For more information, see "
|
|||
| Context name | Type | Description |
|
||||
|---------------|------|-------------|
|
||||
| `github` | `object` | Information about the workflow run. For more information, see [`github` context](#github-context). |
|
||||
| `env` | `object` | Contains environment variables set in a workflow, job, or step. For more information, see [`env` context](#env-context). |
|
||||
| `env` | `object` | Contains variables set in a workflow, job, or step. For more information, see [`env` context](#env-context). |
|
||||
{%- ifversion actions-configuration-variables %}
|
||||
| `vars` | `object` | Contains variables set at the repository, organization, or environment levels. For more information, see [`vars` context](#vars-context). |{% endif %}
|
||||
| `job` | `object` | Information about the currently running job. For more information, see [`job` context](#job-context). |
|
||||
{%- ifversion fpt or ghes > 3.3 or ghae > 3.3 or ghec %}
|
||||
| `jobs` | `object` | For reusable workflows only, contains outputs of jobs from the reusable workflow. For more information, see [`jobs` context](#jobs-context). |{% endif %}
|
||||
|
@ -75,40 +77,40 @@ The following table indicates where each context and special function can be use
|
|||
| Workflow key | Context | Special functions |
|
||||
| ---- | ------- | ----------------- |
|
||||
{%- ifversion actions-run-name %}
|
||||
| <code>run-name</code> | <code>github, inputs</code> | |
|
||||
| <code>run-name</code> | <code>github, inputs{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
{%- endif %}
|
||||
| <code>concurrency</code> | <code>github, inputs</code> | |
|
||||
| <code>env</code> | <code>github, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.concurrency</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.container</code> | <code>github, needs, strategy, matrix, env, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.container.credentials</code> | <code>github, needs, strategy, matrix, env, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.container.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.continue-on-error</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.defaults.run</code> | <code>github, needs, strategy, matrix, env, inputs</code> | |
|
||||
| <code>jobs.<job_id>.env</code> | <code>github, needs, strategy, matrix, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.environment</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.environment.url</code> | <code>github, needs, strategy, matrix, job, runner, env, steps, inputs</code> | |
|
||||
| <code>jobs.<job_id>.if</code> | <code>github, needs, inputs</code> | <code>always, cancelled, success, failure</code> |
|
||||
| <code>jobs.<job_id>.name</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.outputs.<output_id></code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | |
|
||||
| <code>jobs.<job_id>.runs-on</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.secrets.<secrets_id></code> | <code>github, needs,{% ifversion actions-reusable-workflow-matrix %} strategy, matrix,{% endif %} secrets{% ifversion actions-unified-inputs %}, inputs{% endif %}</code> | |
|
||||
| <code>jobs.<job_id>.services</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.credentials</code> | <code>github, needs, strategy, matrix, env, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.steps.continue-on-error</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.env</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.if</code> | <code>github, needs, strategy, matrix, job, runner, env, steps, inputs</code> | <code>always, cancelled, success, failure, hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.name</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.run</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.timeout-minutes</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.with</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.working-directory</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.strategy</code> | <code>github, needs, inputs</code> | |
|
||||
| <code>jobs.<job_id>.timeout-minutes</code> | <code>github, needs, strategy, matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.with.<with_id></code> | <code>github, needs{% ifversion actions-reusable-workflow-matrix %}, strategy, matrix{% endif %}{% ifversion actions-unified-inputs %}, inputs{% endif %}</code> | |
|
||||
| <code>on.workflow_call.inputs.<inputs_id>.default</code> | <code>github{% ifversion actions-unified-inputs %}, inputs{% endif %}</code> | |
|
||||
| <code>on.workflow_call.outputs.<output_id>.value</code> | <code>github, jobs, inputs</code> | |
|
||||
| <code>concurrency</code> | <code>github, inputs{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
| <code>env</code> | <code>github, secrets, inputs{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
| <code>jobs.<job_id>.concurrency</code> | <code>github, needs, strategy, matrix, inputs{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
| <code>jobs.<job_id>.container</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.container.credentials</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.container.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.continue-on-error</code> | <code>github, needs, strategy, {% ifversion actions-configuration-variables %}vars, {% endif %}matrix, inputs</code> | |
|
||||
| <code>jobs.<job_id>.defaults.run</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.env</code> | <code>github, needs, strategy, matrix, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.environment</code> | <code>github, needs, strategy, matrix, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.environment.url</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}steps, inputs</code> | |
|
||||
| <code>jobs.<job_id>.if</code> | <code>github, needs, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | <code>always, cancelled, success, failure</code> |
|
||||
| <code>jobs.<job_id>.name</code> | <code>github, needs, strategy, matrix, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.outputs.<output_id></code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | |
|
||||
| <code>jobs.<job_id>.runs-on</code> | <code>github, needs, strategy, matrix, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.secrets.<secrets_id></code> | <code>github, needs,{% ifversion actions-reusable-workflow-matrix %} strategy, matrix,{% endif %} secrets{% ifversion actions-unified-inputs %}, inputs{% endif %}{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
| <code>jobs.<job_id>.services</code> | <code>github, needs, strategy, matrix, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.credentials</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, inputs</code> | |
|
||||
| <code>jobs.<job_id>.steps.continue-on-error</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.env</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.if</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}steps, inputs</code> | <code>always, cancelled, success, failure, hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.name</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.run</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.timeout-minutes</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.with</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.working-directory</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps, inputs</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.strategy</code> | <code>github, needs, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.timeout-minutes</code> | <code>github, needs, strategy, matrix, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
| <code>jobs.<job_id>.with.<with_id></code> | <code>github, needs{% ifversion actions-reusable-workflow-matrix %}, strategy, matrix{% endif %}{% ifversion actions-unified-inputs %}, inputs{% endif %}{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
| <code>on.workflow_call.inputs.<inputs_id>.default</code> | <code>github{% ifversion actions-unified-inputs %}, inputs{% endif %}{% ifversion actions-configuration-variables %}, vars{% endif %}</code> | |
|
||||
| <code>on.workflow_call.outputs.<output_id>.value</code> | <code>github, jobs, {% ifversion actions-configuration-variables %}vars, {% endif %}inputs</code> | |
|
||||
{% else %}
|
||||
| Path | Context | Special functions |
|
||||
| ---- | ------- | ----------------- |
|
||||
|
@ -116,28 +118,28 @@ The following table indicates where each context and special function can be use
|
|||
| <code>env</code> | <code>github, secrets</code> | |
|
||||
| <code>jobs.<job_id>.concurrency</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.container</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.container.credentials</code> | <code>github, needs, strategy, matrix, env, secrets</code> | |
|
||||
| <code>jobs.<job_id>.container.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, secrets</code> | |
|
||||
| <code>jobs.<job_id>.container.credentials</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets</code> | |
|
||||
| <code>jobs.<job_id>.container.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets</code> | |
|
||||
| <code>jobs.<job_id>.continue-on-error</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.defaults.run</code> | <code>github, needs, strategy, matrix, env</code> | |
|
||||
| <code>jobs.<job_id>.defaults.run</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}</code> | |
|
||||
| <code>jobs.<job_id>.env</code> | <code>github, needs, strategy, matrix, secrets</code> | |
|
||||
| <code>jobs.<job_id>.environment</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.environment.url</code> | <code>github, needs, strategy, matrix, job, runner, env, steps</code> | |
|
||||
| <code>jobs.<job_id>.environment.url</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}steps</code> | |
|
||||
| <code>jobs.<job_id>.if</code> | <code>github, needs</code> | <code>always, cancelled, success, failure</code> |
|
||||
| <code>jobs.<job_id>.name</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.outputs.<output_id></code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | |
|
||||
| <code>jobs.<job_id>.outputs.<output_id></code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | |
|
||||
| <code>jobs.<job_id>.runs-on</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.services</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.credentials</code> | <code>github, needs, strategy, matrix, env, secrets</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, secrets</code> | |
|
||||
| <code>jobs.<job_id>.steps.continue-on-error</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.env</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.if</code> | <code>github, needs, strategy, matrix, job, runner, env, steps</code> | <code>always, cancelled, success, failure, hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.name</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.run</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.timeout-minutes</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.with</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.working-directory</code> | <code>github, needs, strategy, matrix, job, runner, env, secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.services.<service_id>.credentials</code> | <code>github, needs, strategy, matrix, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets</code> | |
|
||||
| <code>jobs.<job_id>.services.<service_id>.env.<env_id></code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets</code> | |
|
||||
| <code>jobs.<job_id>.steps.continue-on-error</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.env</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.if</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}steps</code> | <code>always, cancelled, success, failure, hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.name</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.run</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.timeout-minutes</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.with</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.steps.working-directory</code> | <code>github, needs, strategy, matrix, job, runner, env, {% ifversion actions-configuration-variables %}vars, {% endif %}secrets, steps</code> | <code>hashFiles</code> |
|
||||
| <code>jobs.<job_id>.strategy</code> | <code>github, needs</code> | |
|
||||
| <code>jobs.<job_id>.timeout-minutes</code> | <code>github, needs, strategy, matrix</code> | |
|
||||
{% endif %}
|
||||
|
@ -295,11 +297,11 @@ jobs:
|
|||
|
||||
## `env` context
|
||||
|
||||
The `env` context contains environment variables that have been set in a workflow, job, or step. For more information about setting environment variables in your workflow, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#env)."
|
||||
The `env` context contains variables that have been set in a workflow, job, or step. For more information about setting variables in your workflow, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#env)."
|
||||
|
||||
The `env` context syntax allows you to use the value of an environment variable in your workflow file. You can use the `env` context in the value of any key in a step except for the `id` and `uses` keys. For more information on the step syntax, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps)."
|
||||
The `env` context syntax allows you to use the value of a variable in your workflow file. You can use the `env` context in the value of any key in a step except for the `id` and `uses` keys. For more information on the step syntax, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps)."
|
||||
|
||||
If you want to use the value of an environment variable inside a runner, use the runner operating system's normal method for reading environment variables.
|
||||
If you want to use the value of a variable inside a runner, use the runner operating system's normal method for reading environment variables.
|
||||
|
||||
| Property name | Type | Description |
|
||||
|---------------|------|-------------|
|
||||
|
@ -308,7 +310,7 @@ If you want to use the value of an environment variable inside a runner, use the
|
|||
|
||||
### Example contents of the `env` context
|
||||
|
||||
The contents of the `env` context is a mapping of environment variable names to their values. The context's contents can change depending on where it is used in the workflow run.
|
||||
The contents of the `env` context is a mapping of variable names to their values. The context's contents can change depending on where it is used in the workflow run.
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -348,6 +350,32 @@ jobs:
|
|||
```
|
||||
{% endraw %}
|
||||
|
||||
{% ifversion actions-configuration-variables %}
|
||||
|
||||
## `vars` context
|
||||
|
||||
{% data reusables.actions.configuration-variables-beta-note %}
|
||||
|
||||
The `vars` context contains custom configuration variables set at the organization, repository, and environment levels. For more information about defining configuration variables for use in multiple workflows, see "[Variables](/actions/learn-github-actions/variables#defining-variables-for-multiple-workflows)".
|
||||
|
||||
### Example contents of the `vars` context
|
||||
|
||||
The contents of the `vars` context is a mapping of configuration variable names to their values.
|
||||
|
||||
```json
|
||||
{
|
||||
"mascot": "Mona"
|
||||
}
|
||||
```
|
||||
|
||||
### Example usage of the `vars` context
|
||||
|
||||
This example workflow shows how configuration variables set at the repository, environment, or organization levels are automatically available using the `vars` context.
|
||||
|
||||
{% data reusables.actions.actions-vars-context-example-usage %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
## `job` context
|
||||
|
||||
The `job` context contains information about the currently running job.
|
||||
|
|
|
@ -1,211 +0,0 @@
|
|||
---
|
||||
title: Environment variables
|
||||
intro: '{% data variables.product.prodname_dotcom %} sets default environment variables for each {% data variables.product.prodname_actions %} workflow run. You can also set custom environment variables in your workflow file.'
|
||||
redirect_from:
|
||||
- /github/automating-your-workflow-with-github-actions/using-environment-variables
|
||||
- /actions/automating-your-workflow-with-github-actions/using-environment-variables
|
||||
- /actions/configuring-and-managing-workflows/using-environment-variables
|
||||
- /actions/reference/environment-variables
|
||||
versions:
|
||||
fpt: '*'
|
||||
ghes: '*'
|
||||
ghae: '*'
|
||||
ghec: '*'
|
||||
---
|
||||
|
||||
{% data reusables.actions.enterprise-beta %}
|
||||
{% data reusables.actions.enterprise-github-hosted-runners %}
|
||||
|
||||
## About environment variables
|
||||
|
||||
You can use environment variables to store information that you want to reference in your workflow. You reference environment variables within a workflow step or an action, and the variables are interpolated on the runner machine that runs your workflow. Commands that run in actions or workflow steps can create, read, and modify environment variables.
|
||||
|
||||
You can set your own custom environment variables, you can use the default environment variables that {% data variables.product.prodname_dotcom %} sets automatically, and you can also use any other environment variables that are set in the working environment on the runner. Environment variables are case-sensitive.
|
||||
|
||||
To set a custom environment variable, you must define it in the workflow file. The scope of a custom environment variable is limited to the element in which it is defined. You can define environment variables that are scoped for:
|
||||
|
||||
* The entire workflow, by using [`env`](/actions/using-workflows/workflow-syntax-for-github-actions#env) at the top level of the workflow file.
|
||||
* The contents of a job within a workflow, by using [`jobs.<job_id>.env`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenv).
|
||||
* A specific step within a job, by using [`jobs.<job_id>.steps[*].env`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsenv).
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
name: Greeting on variable day
|
||||
|
||||
on:
|
||||
workflow_dispatch
|
||||
|
||||
env:
|
||||
DAY_OF_WEEK: Monday
|
||||
|
||||
jobs:
|
||||
greeting_job:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Greeting: Hello
|
||||
steps:
|
||||
- name: "Say Hello Mona it's Monday"
|
||||
run: echo "$Greeting $First_Name. Today is $DAY_OF_WEEK!"
|
||||
env:
|
||||
First_Name: Mona
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
The example above shows three custom environment variables being used in an `echo` command: `$DAY_OF_WEEK`, `$Greeting`, and `$First_Name`. The values for these environment variables are set, and scoped, at the workflow, job, and step level respectively.
|
||||
|
||||
Because environment variable interpolation is done after a workflow job is sent to a runner machine, you must use the appropriate syntax for the shell that's used on the runner. In this example, the workflow specifies `ubuntu-latest`. By default, Linux runners use the bash shell, so you must use the syntax `$NAME`. If the workflow specified a Windows runner, you would use the syntax for PowerShell, `$env:NAME`. For more information about shells, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsshell)."
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note**: You can list the entire set of environment variables that are available to a workflow step by using <span style="white-space: nowrap;">`run: env`</span> in a step and then examining the output for the step.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
## Using contexts to access environment variable values
|
||||
|
||||
In addition to environment variables, {% data variables.product.prodname_actions %} also allows you to set and read values using contexts. Environment variables and contexts are intended for use at different points in the workflow.
|
||||
|
||||
Environment variables are always interpolated on the virtual machine runner. However, parts of a workflow are processed by {% data variables.product.prodname_actions %} and are not sent to the runner. You cannot use environment variables in these parts of a workflow file. Instead, you can use contexts. For example, an `if` conditional, which determines whether a job or step is sent to the runner, is always processed by {% data variables.product.prodname_actions %}. You can use a context in an `if` conditional statement to access the value of an environment variable.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
env:
|
||||
DAY_OF_WEEK: Monday
|
||||
|
||||
jobs:
|
||||
greeting_job:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Greeting: Hello
|
||||
steps:
|
||||
- name: "Say Hello Mona it's Monday"
|
||||
if: ${{ env.DAY_OF_WEEK == 'Monday' }}
|
||||
run: echo "$Greeting $First_Name. Today is $DAY_OF_WEEK!"
|
||||
env:
|
||||
First_Name: Mona
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
In this modification of the first example, we've introduced an `if` conditional. The workflow step is now only run if `DAYS_OF_WEEK` is set to "Monday". We access this value from the `if` conditional statement by using the [`env` context](/actions/learn-github-actions/contexts#env-context).
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note**: Contexts are usually denoted using the dollar sign and curly braces, as {% raw %}`${{ context.property }}`{% endraw %}. In an `if` conditional, the {% raw %}`${{` and `}}`{% endraw %} are optional, but if you use them they must enclose the entire comparison statement, as shown above.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
You will commonly use either the `env` or `github` context to access environment variable values in parts of the workflow that are processed before jobs are sent to runners.
|
||||
|
||||
|
||||
| Context | Use case | Example |
|
||||
| --- | --- | --- |
|
||||
| `env` | Reference custom environment variables defined in the workflow. | <span style="white-space: nowrap;">{% raw %}`${{ env.MY_VARIABLE }}`{% endraw %}</span> |
|
||||
| `github` | Reference information about the workflow run and the event that triggered the run. | <span style="white-space: nowrap;">{% raw %}`${{ github.repository }}`{% endraw %}</span> |
|
||||
|
||||
|
||||
|
||||
There are many other contexts that you can use for a variety of purposes in your workflows. For more information, see "[Contexts](/actions/learn-github-actions/contexts)." For details of where you can use specific contexts within a workflow, see "[Context availability](/actions/learn-github-actions/contexts#context-availability)."
|
||||
|
||||
### Other types of variables
|
||||
|
||||
In most places in a workflow, the only types of variables that you can use are either environment variables, such as `$MY_VARIABLE`, or the equivalent context property, such as <span style="white-space: nowrap;">{% raw %}`${{ env.MY_VARIABLE }}`{% endraw %}</span>. Exceptions are:
|
||||
|
||||
* Inputs for the `workflow_call` and `workflow_dispatch` events, which allow you to pass values to a workflow. For more information, see [`on.workflow_call.inputs`](/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs) and [`on.workflow_dispatch.inputs`](/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_dispatchinputs).
|
||||
* Job outputs, which allow you to pass values between jobs in a workflow. For more information, see [`jobs.<job_id>.outputs`](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs).
|
||||
* The variables in a format expression, which allow you to replace parts of a string. For more information, see [`format`](/actions/learn-github-actions/expressions#format).
|
||||
|
||||
## Naming conventions for environment variables
|
||||
|
||||
When you set a custom environment variable, you cannot use any of the default environment variable names. For a complete list of these, see "[Default environment variables](#default-environment-variables)" below. If you attempt to override the value of one of these default environment variables, the assignment is ignored.
|
||||
|
||||
Any new environment variables you set that point to a location on the filesystem should have a `_PATH` suffix. The `GITHUB_ENV` and `GITHUB_WORKSPACE` default environment variables are exceptions to this convention.
|
||||
|
||||
## Default environment variables
|
||||
|
||||
The default environment variables that {% data variables.product.prodname_dotcom %} sets are available to every step in a workflow.
|
||||
|
||||
We strongly recommend that actions use environment variables to access the filesystem rather than using hardcoded file paths. {% data variables.product.prodname_dotcom %} sets environment variables for actions to use in all runner environments.
|
||||
|
||||
| Environment variable | Description |
|
||||
| ---------------------|------------ |
|
||||
| `CI` | Always set to `true`. |
|
||||
| `GITHUB_ACTION` | The name of the action currently running, or the [`id`](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsid) of a step. For example, for an action, `__repo-owner_name-of-action-repo`.<br><br>{% data variables.product.prodname_dotcom %} removes special characters, and uses the name `__run` when the current step runs a script without an `id`. If you use the same script or action more than once in the same job, the name will include a suffix that consists of the sequence number preceded by an underscore. For example, the first script you run will have the name `__run`, and the second script will be named `__run_2`. Similarly, the second invocation of `actions/checkout` will be `actionscheckout2`. |
|
||||
| `GITHUB_ACTION_PATH` | The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action. For example, `/home/runner/work/_actions/repo-owner/name-of-action-repo/v1`. |
|
||||
| `GITHUB_ACTION_REPOSITORY` | For a step executing an action, this is the owner and repository name of the action. For example, `actions/checkout`. |
|
||||
| `GITHUB_ACTIONS` | Always set to `true` when {% data variables.product.prodname_actions %} is running the workflow. You can use this variable to differentiate when tests are being run locally or by {% data variables.product.prodname_actions %}.
|
||||
| `GITHUB_ACTOR` | The name of the person or app that initiated the workflow. For example, `octocat`. |
|
||||
| `GITHUB_API_URL` | Returns the API URL. For example: `{% data variables.product.api_url_code %}`.
|
||||
| `GITHUB_BASE_REF` | The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `main`. |
|
||||
| `GITHUB_ENV` | The path on the runner to the file that sets environment variables from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_env_87406d6e-4979-4d42-98e1-3dab1f48b13a`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable)." |
|
||||
| `GITHUB_EVENT_NAME` | The name of the event that triggered the workflow. For example, `workflow_dispatch`. |
|
||||
| `GITHUB_EVENT_PATH` | The path to the file on the runner that contains the full event webhook payload. For example, `/github/workflow/event.json`. |
|
||||
| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example: `{% data variables.product.graphql_url_code %}`.
|
||||
| `GITHUB_HEAD_REF` | The head ref or source branch of the pull request in a workflow run. This property is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `feature-branch-1`. |
|
||||
| `GITHUB_JOB` | The [job_id](/actions/reference/workflow-syntax-for-github-actions#jobsjob_id) of the current job. For example, `greeting_job`. |
|
||||
| `GITHUB_PATH` | The path on the runner to the file that sets system `PATH` variables from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/add_path_899b9445-ad4a-400c-aa89-249f18632cf5`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path)." |
|
||||
| `GITHUB_REF` | {% data reusables.actions.ref-description %} |
|
||||
{%- ifversion fpt or ghec or ghes > 3.3 or ghae > 3.3 %}
|
||||
| `GITHUB_REF_NAME` | {% data reusables.actions.ref_name-description %} |
|
||||
| `GITHUB_REF_PROTECTED` | {% data reusables.actions.ref_protected-description %} |
|
||||
| `GITHUB_REF_TYPE` | {% data reusables.actions.ref_type-description %} |
|
||||
{%- endif %}
|
||||
| `GITHUB_REPOSITORY` | The owner and repository name. For example, `octocat/Hello-World`. |
|
||||
| `GITHUB_REPOSITORY_OWNER` | The repository owner's name. For example, `octocat`. |
|
||||
| `GITHUB_RETENTION_DAYS` | The number of days that workflow run logs and artifacts are kept. For example, `90`. |
|
||||
| `GITHUB_RUN_ATTEMPT` | A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run. For example, `3`. |
|
||||
| `GITHUB_RUN_ID` | {% data reusables.actions.run_id_description %} For example, `1658821493`. |
|
||||
| `GITHUB_RUN_NUMBER` | {% data reusables.actions.run_number_description %} For example, `3`. |
|
||||
| `GITHUB_SERVER_URL`| The URL of the {% data variables.product.product_name %} server. For example: `https://{% data variables.product.product_url %}`.
|
||||
| `GITHUB_SHA` | {% data reusables.actions.github_sha_description %} |
|
||||
{%- ifversion actions-job-summaries %}
|
||||
| `GITHUB_STEP_SUMMARY` | The path on the runner to the file that contains job summaries from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/rob/runner/_layout/_work/_temp/_runner_file_commands/step_summary_1cb22d7f-5663-41a8-9ffc-13472605c76c`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary)." |
|
||||
{%- endif %}
|
||||
| `GITHUB_WORKFLOW` | The name of the workflow. For example, `My test workflow`. If the workflow file doesn't specify a `name`, the value of this variable is the full path of the workflow file in the repository. |
|
||||
| `GITHUB_WORKSPACE` | The default working directory on the runner for steps, and the default location of your repository when using the [`checkout`](https://github.com/actions/checkout) action. For example, `/home/runner/work/my-repo-name/my-repo-name`. |
|
||||
{%- ifversion actions-runner-arch-envvars %}
|
||||
| `RUNNER_ARCH` | {% data reusables.actions.runner-arch-description %} |
|
||||
{%- endif %}
|
||||
| `RUNNER_DEBUG` | {% data reusables.actions.runner-debug-description %} |
|
||||
| `RUNNER_NAME` | {% data reusables.actions.runner-name-description %} For example, `Hosted Agent` |
|
||||
| `RUNNER_OS` | {% data reusables.actions.runner-os-description %} For example, `Windows` |
|
||||
| `RUNNER_TEMP` | {% data reusables.actions.runner-temp-directory-description %} For example, `D:\a\_temp` |
|
||||
{%- ifversion not ghae %}
|
||||
| `RUNNER_TOOL_CACHE` | {% data reusables.actions.runner-tool-cache-description %} For example, `C:\hostedtoolcache\windows` |
|
||||
{%- endif %}
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note:**
|
||||
|
||||
* If you need to use a workflow run's URL from within a job, you can combine these environment variables: `$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID`
|
||||
* Most of the default environment variables have a corresponding, and similarly named, context property. For example, the value of the `GITHUB_REF` environment variable can be read during workflow processing using the {% raw %}`${{ github.ref }}`{% endraw %} context property.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
## Detecting the operating system
|
||||
|
||||
You can write a single workflow file that can be used for different operating systems by using the `RUNNER_OS` default environment variable and the corresponding context property <span style="white-space: nowrap;">{% raw %}`${{ runner.os }}`{% endraw %}</span>. For example, the following workflow could be run successfully if you changed the operating system from `macos-latest` to `windows-latest` without having to alter the syntax of the environment variables, which differs depending on the shell being used by the runner.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
jobs:
|
||||
if-Windows-else:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: condition 1
|
||||
if: runner.os == 'Windows'
|
||||
run: echo "The operating system on the runner is $env:RUNNER_OS."
|
||||
- name: condition 2
|
||||
if: runner.os != 'Windows'
|
||||
run: echo "The operating system on the runner is not Windows, it's $RUNNER_OS."
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
In this example, the two `if` statements check the `os` property of the `runner` context to determine the operating system of the runner. `if` conditionals are processed by {% data variables.product.prodname_actions %}, and only steps where the check resolves as `true` are sent to the runner. Here one of the checks will always be `true` and the other `false`, so only one of these steps is sent to the runner. Once the job is sent to the runner, the step is executed and the environment variable in the `echo` command is interpolated using the appropriate syntax (`$env:NAME` for PowerShell on Windows, and `$NAME` for bash and sh on Linux and MacOS). In this example, the statement `runs-on: macos-latest` means that the second step will be run.
|
||||
|
||||
## Passing values between steps and jobs in a workflow
|
||||
|
||||
If you generate a value in one step of a job, you can use the value in subsequent steps of the same job by assigning the value to an existing or new environment variable and then writing this to the `GITHUB_ENV` environment file. The environment file can be used directly by an action, or from a shell command in the workflow file by using the `run` keyword. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions/#setting-an-environment-variable)."
|
||||
|
||||
If you want to pass a value from a step in one job in a workflow to a step in another job in the workflow, you can define the value as a job output. You can then reference this job output from a step in another job. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs)."
|
||||
|
|
@ -34,7 +34,7 @@ jobs:
|
|||
POSTGRES_PORT: 5432
|
||||
```
|
||||
|
||||
For more information, see "[Using environment variables](/actions/configuring-and-managing-workflows/using-environment-variables)."
|
||||
For more information, see "[Variables](/actions/learn-github-actions/variables#default-environment-variables)."
|
||||
|
||||
## Adding scripts to your workflow
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ children:
|
|||
- /essential-features-of-github-actions
|
||||
- /expressions
|
||||
- /contexts
|
||||
- /environment-variables
|
||||
- /variables
|
||||
- /usage-limits-billing-and-administration
|
||||
---
|
||||
|
||||
|
|
|
@ -0,0 +1,317 @@
|
|||
---
|
||||
title: Variables
|
||||
intro: '{% data variables.product.prodname_dotcom %} sets default variables for each {% data variables.product.prodname_actions %} workflow run. {% ifversion actions-configuration-variables %}You can also set custom variables for use in a single workflow or multiple workflows. {% else %}You can also set custom variables in your workflow file.{% endif %}'
|
||||
redirect_from:
|
||||
- /github/automating-your-workflow-with-github-actions/using-environment-variables
|
||||
- /actions/automating-your-workflow-with-github-actions/using-environment-variables
|
||||
- /actions/configuring-and-managing-workflows/using-environment-variables
|
||||
- /actions/reference/environment-variables
|
||||
- /actions/learn-github-actions/environment-variables
|
||||
versions:
|
||||
fpt: '*'
|
||||
ghes: '*'
|
||||
ghae: '*'
|
||||
ghec: '*'
|
||||
miniTocMaxHeadingLevel: 3
|
||||
---
|
||||
|
||||
{% data reusables.actions.enterprise-beta %}
|
||||
{% data reusables.actions.enterprise-github-hosted-runners %}
|
||||
|
||||
## About variables
|
||||
|
||||
{% ifversion actions-configuration-variables %}
|
||||
|
||||
Variables provide a way to store and reuse non-sensitive configuration information. You can store any configuration data such as compiler flags, usernames, or server names as variables. Variables are interpolated on the runner machine that runs your workflow. Commands that run in actions or workflow steps can create, read, and modify variables.
|
||||
|
||||
You can set your own custom variables or use the default environment variables that {% data variables.product.prodname_dotcom %} sets automatically. For more information, see "[Default environment variables](#default-environment-variables)".
|
||||
|
||||
You can set a custom variable in two ways.
|
||||
|
||||
- To define an environment variable for use in a single workflow, you can use the `env` key in the workflow file. For more information, see "[Defining environment variables for a single workflow](#defining-environment-variables-for-a-single-workflow)".
|
||||
- To define a configuration variable across multiple workflows, you can define it at the organization, repository, or environment level. For more information, see "[Defining configuration variables for multiple workflows](#defining-configuration-variables-for-a-multiple-workflows)".
|
||||
|
||||
{% warning %}
|
||||
|
||||
**Warning:** By default, variables render unmasked in your build outputs. If you need greater security for sensitive information, such as passwords, use encrypted secrets instead. For more information, see "[Encrypted secrets](/actions/security-guides/encrypted-secrets)".
|
||||
|
||||
{% endwarning %}
|
||||
|
||||
{% else %}
|
||||
|
||||
You can use variables to store information that you want to reference in your workflow. You reference variables within a workflow step or an action, and the variables are interpolated on the runner machine that runs your workflow. Commands that run in actions or workflow steps can create, read, and modify variables.
|
||||
|
||||
You can set your own custom variables, you can use the default variables that {% data variables.product.prodname_dotcom %} sets automatically, and you can also use any other variables that are set in the working environment on the runner. Variables are case-sensitive.
|
||||
|
||||
{% endif %}
|
||||
|
||||
## Defining environment variables{% ifversion actions-configuration-variables %} for a single workflow{% endif %}
|
||||
|
||||
To set a custom environment variable{% ifversion actions-configuration-variables %} for a single workflow{% endif %}, you can define it using the `env` key in the workflow file. The scope of a custom variable set by this method is limited to the element in which it is defined. You can define variables that are scoped for:
|
||||
|
||||
* The entire workflow, by using [`env`](/actions/using-workflows/workflow-syntax-for-github-actions#env) at the top level of the workflow file.
|
||||
* The contents of a job within a workflow, by using [`jobs.<job_id>.env`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenv).
|
||||
* A specific step within a job, by using [`jobs.<job_id>.steps[*].env`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsenv).
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
name: Greeting on variable day
|
||||
|
||||
on:
|
||||
workflow_dispatch
|
||||
|
||||
env:
|
||||
DAY_OF_WEEK: Monday
|
||||
|
||||
jobs:
|
||||
greeting_job:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Greeting: Hello
|
||||
steps:
|
||||
- name: "Say Hello Mona it's Monday"
|
||||
run: echo "$Greeting $First_Name. Today is $DAY_OF_WEEK!"
|
||||
env:
|
||||
First_Name: Mona
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
You can access `env` variable values using runner environment variables or using contexts. The above example above shows three custom variables being used as environment variables in an `echo` command: `$DAY_OF_WEEK`, `$Greeting`, and `$First_Name`. The values for these variables are set, and scoped, at the workflow, job, and step level respectively. For more information on accessing variable values using contexts, see "[Using contexts to access variable values](#using-contexts-to-access-variable-values)."
|
||||
|
||||
Because runner environment variable interpolation is done after a workflow job is sent to a runner machine, you must use the appropriate syntax for the shell that's used on the runner. In this example, the workflow specifies `ubuntu-latest`. By default, Linux runners use the bash shell, so you must use the syntax `$NAME`. If the workflow specified a Windows runner, you would use the syntax for PowerShell, `$env:NAME`. For more information about shells, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsshell)."
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note**: You can list the entire set of environment variables that are available to a workflow step by using <span style="white-space: nowrap;">`run: env`</span> in a step and then examining the output for the step.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
{% ifversion actions-configuration-variables %}
|
||||
|
||||
## Defining configuration variables for multiple workflows
|
||||
|
||||
{% data reusables.actions.configuration-variables-beta-note %}
|
||||
|
||||
You can create configuration variables for use across multiple workflows, and can define them at either the [organization](#creating-configuration-variables-for-an-organization), [repository](#creating-configuration-variables-for-a-repository), or [environment](#creating-configuration-variables-for-an-environment) level.
|
||||
|
||||
For example, you can use configuration variables to set default values for parameters passed to build tools at an organization level, but then allow repository owners to override these parameters on a case-by-case basis.
|
||||
|
||||
When you define configuration variables, they are automatically available in the `vars` context. For more information, see "[Using the `vars `context to access configuration variable values](#using-the-vars-context-to-access-configuration-variable-values)".
|
||||
|
||||
### Configuration variable precedence
|
||||
|
||||
If a variable with the same name exists at multiple levels, the variable at the lowest level takes precedence. For example, if an organization-level variable has the same name as a repository-level variable, then the repository-level variable takes precedence. Similarly, if an organization, repository, and environment all have a variable with the same name, the environment-level variable takes precedence.
|
||||
|
||||
If a repository contains reusable workflows, its configuration variables are automatically made available to the caller workflows with the `vars` context. However, if the same variable name is used in the caller and the called workflow repositories, the variable from the caller workflow repository is be used.
|
||||
|
||||
### Naming conventions for configuration variables
|
||||
|
||||
When you set a custom variable, you cannot use any of the default environment variable names. For a complete list of default environment variables, see "[Default environment variables](#default-environment-variables)" below. If you attempt to override the value of one of these default variables, the assignment is ignored.
|
||||
|
||||
Any new variables you set that point to a location on the filesystem should have a `_PATH` suffix. The `GITHUB_ENV` and `GITHUB_WORKSPACE` default variables are exceptions to this convention.
|
||||
|
||||
The following rules apply to configuration variable names:
|
||||
|
||||
{% data reusables.actions.actions-secrets-and-variables-naming %}
|
||||
|
||||
### Creating configuration variables for a repository
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-variables-repository %}
|
||||
|
||||
{% data reusables.repositories.navigate-to-repo %}
|
||||
{% data reusables.repositories.sidebar-settings %}
|
||||
{% data reusables.actions.sidebar-secrets-and-variables %}
|
||||
{% data reusables.actions.actions-variables-tab %}
|
||||
![Repository variables tab](/assets/images/help/repository/actions-variables-tab.png)
|
||||
1. Click **New repository variable**.
|
||||
{% data reusables.actions.variable-fields %}
|
||||
1. Click **Add variable**.
|
||||
|
||||
### Creating configuration variables for an environment
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-environment %}
|
||||
|
||||
{% data reusables.repositories.navigate-to-repo %}
|
||||
{% data reusables.repositories.sidebar-settings %}
|
||||
{% data reusables.actions.sidebar-environment %}
|
||||
1. Click on the environment that you want to add a variable to.
|
||||
1. Under **Environment variables**, click **Add variable**.
|
||||
{% data reusables.actions.variable-fields %}
|
||||
1. Click **Add variable**.
|
||||
|
||||
### Creating configuration variables for an organization
|
||||
|
||||
{% data reusables.actions.actions-secrets-variables-repository-access %}
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-and-variables-organization %}
|
||||
|
||||
{% data reusables.organizations.navigate-to-org %}
|
||||
{% data reusables.organizations.org_settings %}
|
||||
{% data reusables.actions.sidebar-secrets-and-variables %}
|
||||
{% data reusables.actions.actions-variables-tab %}
|
||||
![Organization variables tab](/assets/images/help/organizations/actions-organization-variables-tab.png)
|
||||
1. Click **New organization variable**.
|
||||
{% data reusables.actions.variable-fields %}
|
||||
1. From the **Repository access** dropdown list, choose an access policy.
|
||||
1. Click **Add variable**.
|
||||
|
||||
### Limits for configuration variables
|
||||
|
||||
You can store up to 1,000 organization variables, 100 repository variables, and 100 environment variables.
|
||||
|
||||
A workflow created in a repository can access the following number of variables:
|
||||
|
||||
* All 100 repository variables.
|
||||
* If the repository is assigned access to more than 100 organization variables, the workflow can only use the first 100 organization variables (sorted alphabetically by variable name).
|
||||
* All 100 environment variables.
|
||||
|
||||
Variables are limited to 64 KB in size.
|
||||
|
||||
{% endif %}
|
||||
|
||||
## Using contexts to access variable values
|
||||
|
||||
{% data reusables.actions.actions-contexts-about-description %} For more information, see "[Contexts](/actions/learn-github-actions/contexts)". There are many other contexts that you can use for a variety of purposes in your workflows. For details of where you can use specific contexts within a workflow, see "[Context availability](/actions/learn-github-actions/contexts#context-availability)."
|
||||
|
||||
You can access environment variable values using the `env` context{% ifversion actions-configuration-variables %} and configuration variable values using the `vars` context{% endif %}.
|
||||
|
||||
### Using the `env` context to access environment variable values
|
||||
|
||||
In addition to runner environment variables, {% data variables.product.prodname_actions %} allows you to set and read `env` key values using contexts. Environment variables and contexts are intended for use at different points in the workflow.
|
||||
|
||||
Runner environment variables are always interpolated on the runner machine. However, parts of a workflow are processed by {% data variables.product.prodname_actions %} and are not sent to the runner. You cannot use environment variables in these parts of a workflow file. Instead, you can use contexts. For example, an `if` conditional, which determines whether a job or step is sent to the runner, is always processed by {% data variables.product.prodname_actions %}. You can use a context in an `if` conditional statement to access the value of an variable.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
env:
|
||||
DAY_OF_WEEK: Monday
|
||||
|
||||
jobs:
|
||||
greeting_job:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Greeting: Hello
|
||||
steps:
|
||||
- name: "Say Hello Mona it's Monday"
|
||||
if: ${{ env.DAY_OF_WEEK == 'Monday' }}
|
||||
run: echo "$Greeting $First_Name. Today is $DAY_OF_WEEK!"
|
||||
env:
|
||||
First_Name: Mona
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
In this modification of the earlier example, we've introduced an `if` conditional. The workflow step is now only run if `DAYS_OF_WEEK` is set to "Monday". We access this value from the `if` conditional statement by using the [`env` context](/actions/learn-github-actions/contexts#env-context).
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note**: Contexts are usually denoted using the dollar sign and curly braces, as {% raw %}`${{ context.property }}`{% endraw %}. In an `if` conditional, the {% raw %}`${{` and `}}`{% endraw %} are optional, but if you use them they must enclose the entire comparison statement, as shown above.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
You will commonly use either the `env` or `github` context to access variable values in parts of the workflow that are processed before jobs are sent to runners.
|
||||
|
||||
|
||||
| Context | Use case | Example |
|
||||
| --- | --- | --- |
|
||||
| `env` | Reference custom variables defined in the workflow. | <span style="white-space: nowrap;">{% raw %}`${{ env.MY_VARIABLE }}`{% endraw %}</span> |
|
||||
| `github` | Reference information about the workflow run and the event that triggered the run. | <span style="white-space: nowrap;">{% raw %}`${{ github.repository }}`{% endraw %}</span> |
|
||||
|
||||
{% ifversion actions-configuration-variables %}
|
||||
|
||||
### Using the `vars` context to access configuration variable values
|
||||
|
||||
Configuration variables can be accessed across the workflow using `vars` context. For more information, see "[Contexts](/actions/learn-github-actions/contexts#vars-context)".
|
||||
|
||||
{% data reusables.actions.actions-vars-context-example-usage %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
## Default environment variables
|
||||
|
||||
The default environment variables that {% data variables.product.prodname_dotcom %} sets are available to every step in a workflow.
|
||||
|
||||
We strongly recommend that actions use variables to access the filesystem rather than using hardcoded file paths. {% data variables.product.prodname_dotcom %} sets variables for actions to use in all runner environments.
|
||||
|
||||
| Variable | Description |
|
||||
| ---------|------------ |
|
||||
| `CI` | Always set to `true`. |
|
||||
| `GITHUB_ACTION` | The name of the action currently running, or the [`id`](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsid) of a step. For example, for an action, `__repo-owner_name-of-action-repo`.<br><br>{% data variables.product.prodname_dotcom %} removes special characters, and uses the name `__run` when the current step runs a script without an `id`. If you use the same script or action more than once in the same job, the name will include a suffix that consists of the sequence number preceded by an underscore. For example, the first script you run will have the name `__run`, and the second script will be named `__run_2`. Similarly, the second invocation of `actions/checkout` will be `actionscheckout2`. |
|
||||
| `GITHUB_ACTION_PATH` | The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action. For example, `/home/runner/work/_actions/repo-owner/name-of-action-repo/v1`. |
|
||||
| `GITHUB_ACTION_REPOSITORY` | For a step executing an action, this is the owner and repository name of the action. For example, `actions/checkout`. |
|
||||
| `GITHUB_ACTIONS` | Always set to `true` when {% data variables.product.prodname_actions %} is running the workflow. You can use this variable to differentiate when tests are being run locally or by {% data variables.product.prodname_actions %}.
|
||||
| `GITHUB_ACTOR` | The name of the person or app that initiated the workflow. For example, `octocat`. |
|
||||
| `GITHUB_API_URL` | Returns the API URL. For example: `{% data variables.product.api_url_code %}`.
|
||||
| `GITHUB_BASE_REF` | The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `main`. |
|
||||
| `GITHUB_ENV` | The path on the runner to the file that sets variables from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_env_87406d6e-4979-4d42-98e1-3dab1f48b13a`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable)." |
|
||||
| `GITHUB_EVENT_NAME` | The name of the event that triggered the workflow. For example, `workflow_dispatch`. |
|
||||
| `GITHUB_EVENT_PATH` | The path to the file on the runner that contains the full event webhook payload. For example, `/github/workflow/event.json`. |
|
||||
| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example: `{% data variables.product.graphql_url_code %}`.
|
||||
| `GITHUB_HEAD_REF` | The head ref or source branch of the pull request in a workflow run. This property is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `feature-branch-1`. |
|
||||
| `GITHUB_JOB` | The [job_id](/actions/reference/workflow-syntax-for-github-actions#jobsjob_id) of the current job. For example, `greeting_job`. |
|
||||
| `GITHUB_PATH` | The path on the runner to the file that sets system `PATH` variables from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/add_path_899b9445-ad4a-400c-aa89-249f18632cf5`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path)." |
|
||||
| `GITHUB_REF` | {% data reusables.actions.ref-description %} |
|
||||
{%- ifversion fpt or ghec or ghes > 3.3 or ghae > 3.3 %}
|
||||
| `GITHUB_REF_NAME` | {% data reusables.actions.ref_name-description %} |
|
||||
| `GITHUB_REF_PROTECTED` | {% data reusables.actions.ref_protected-description %} |
|
||||
| `GITHUB_REF_TYPE` | {% data reusables.actions.ref_type-description %} |
|
||||
{%- endif %}
|
||||
| `GITHUB_REPOSITORY` | The owner and repository name. For example, `octocat/Hello-World`. |
|
||||
| `GITHUB_REPOSITORY_OWNER` | The repository owner's name. For example, `octocat`. |
|
||||
| `GITHUB_RETENTION_DAYS` | The number of days that workflow run logs and artifacts are kept. For example, `90`. |
|
||||
| `GITHUB_RUN_ATTEMPT` | A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run. For example, `3`. |
|
||||
| `GITHUB_RUN_ID` | {% data reusables.actions.run_id_description %} For example, `1658821493`. |
|
||||
| `GITHUB_RUN_NUMBER` | {% data reusables.actions.run_number_description %} For example, `3`. |
|
||||
| `GITHUB_SERVER_URL`| The URL of the {% data variables.product.product_name %} server. For example: `https://{% data variables.product.product_url %}`.
|
||||
| `GITHUB_SHA` | {% data reusables.actions.github_sha_description %} |
|
||||
{%- ifversion actions-job-summaries %}
|
||||
| `GITHUB_STEP_SUMMARY` | The path on the runner to the file that contains job summaries from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/rob/runner/_layout/_work/_temp/_runner_file_commands/step_summary_1cb22d7f-5663-41a8-9ffc-13472605c76c`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary)." |
|
||||
{%- endif %}
|
||||
| `GITHUB_WORKFLOW` | The name of the workflow. For example, `My test workflow`. If the workflow file doesn't specify a `name`, the value of this variable is the full path of the workflow file in the repository. |
|
||||
| `GITHUB_WORKSPACE` | The default working directory on the runner for steps, and the default location of your repository when using the [`checkout`](https://github.com/actions/checkout) action. For example, `/home/runner/work/my-repo-name/my-repo-name`. |
|
||||
{%- ifversion actions-runner-arch-envvars %}
|
||||
| `RUNNER_ARCH` | {% data reusables.actions.runner-arch-description %} |
|
||||
{%- endif %}
|
||||
| `RUNNER_DEBUG` | {% data reusables.actions.runner-debug-description %} |
|
||||
| `RUNNER_NAME` | {% data reusables.actions.runner-name-description %} For example, `Hosted Agent` |
|
||||
| `RUNNER_OS` | {% data reusables.actions.runner-os-description %} For example, `Windows` |
|
||||
| `RUNNER_TEMP` | {% data reusables.actions.runner-temp-directory-description %} For example, `D:\a\_temp` |
|
||||
{%- ifversion not ghae %}
|
||||
| `RUNNER_TOOL_CACHE` | {% data reusables.actions.runner-tool-cache-description %} For example, `C:\hostedtoolcache\windows` |
|
||||
{%- endif %}
|
||||
|
||||
{% note %}
|
||||
|
||||
**Note:**
|
||||
|
||||
* If you need to use a workflow run's URL from within a job, you can combine these variables: `$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID`
|
||||
* Most of the default variables have a corresponding, and similarly named, context property. For example, the value of the `GITHUB_REF` variable can be read during workflow processing using the {% raw %}`${{ github.ref }}`{% endraw %} context property.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
## Detecting the operating system
|
||||
|
||||
You can write a single workflow file that can be used for different operating systems by using the `RUNNER_OS` default environment variable and the corresponding context property <span style="white-space: nowrap;">{% raw %}`${{ runner.os }}`{% endraw %}</span>. For example, the following workflow could be run successfully if you changed the operating system from `macos-latest` to `windows-latest` without having to alter the syntax of the environment variables, which differs depending on the shell being used by the runner.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
jobs:
|
||||
if-Windows-else:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: condition 1
|
||||
if: runner.os == 'Windows'
|
||||
run: echo "The operating system on the runner is $env:RUNNER_OS."
|
||||
- name: condition 2
|
||||
if: runner.os != 'Windows'
|
||||
run: echo "The operating system on the runner is not Windows, it's $RUNNER_OS."
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
In this example, the two `if` statements check the `os` property of the `runner` context to determine the operating system of the runner. `if` conditionals are processed by {% data variables.product.prodname_actions %}, and only steps where the check resolves as `true` are sent to the runner. Here one of the checks will always be `true` and the other `false`, so only one of these steps is sent to the runner. Once the job is sent to the runner, the step is executed and the environment variable in the `echo` command is interpolated using the appropriate syntax (`$env:NAME` for PowerShell on Windows, and `$NAME` for bash and sh on Linux and MacOS). In this example, the statement `runs-on: macos-latest` means that the second step will be run.
|
||||
|
||||
## Passing values between steps and jobs in a workflow
|
||||
|
||||
If you generate a value in one step of a job, you can use the value in subsequent steps of the same job by assigning the value to an existing or new environment variable and then writing this to the `GITHUB_ENV` environment file. The environment file can be used directly by an action, or from a shell command in the workflow file by using the `run` keyword. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions/#setting-an-environment-variable)."
|
||||
|
||||
If you want to pass a value from a step in one job in a workflow to a step in another job in the workflow, you can define the value as a job output. You can then reference this job output from a step in another job. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs)."
|
||||
|
|
@ -73,9 +73,9 @@ For more information about the tools and packages available on {% data variables
|
|||
|
||||
## Using variables and secrets
|
||||
|
||||
CircleCI and {% data variables.product.prodname_actions %} support setting environment variables in the configuration file and creating secrets using the CircleCI or {% data variables.product.product_name %} UI.
|
||||
CircleCI and {% data variables.product.prodname_actions %} support setting variables in the configuration file and creating secrets using the CircleCI or {% data variables.product.product_name %} UI.
|
||||
|
||||
For more information, see "[Using environment variables](/actions/configuring-and-managing-workflows/using-environment-variables)" and "[Creating and using encrypted secrets](/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)."
|
||||
For more information, see "[Variables](/actions/learn-github-actions/variables#default-environment-variables)" and "[Creating and using encrypted secrets](/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)."
|
||||
|
||||
## Caching
|
||||
|
||||
|
|
|
@ -301,9 +301,9 @@ For more information, see "[Events that trigger workflows](/actions/reference/ev
|
|||
|
||||
## Variables and secrets
|
||||
|
||||
GitLab CI/CD and {% data variables.product.prodname_actions %} support setting environment variables in the pipeline or workflow configuration file, and creating secrets using the GitLab or {% data variables.product.product_name %} UI.
|
||||
GitLab CI/CD and {% data variables.product.prodname_actions %} support setting variables in the pipeline or workflow configuration file, and creating secrets using the GitLab or {% data variables.product.product_name %} UI.
|
||||
|
||||
For more information, see "[Environment variables](/actions/reference/environment-variables)" and "[Encrypted secrets](/actions/reference/encrypted-secrets)."
|
||||
For more information, see "[Variables](/actions/learn-github-actions/variables)" and "[Encrypted secrets](/actions/reference/encrypted-secrets)."
|
||||
|
||||
## Caching
|
||||
|
||||
|
|
|
@ -43,13 +43,13 @@ To give you control over when CI tasks are executed, a {% data variables.product
|
|||
|
||||
Travis CI and {% data variables.product.prodname_actions %} both use YAML to create jobs and workflows, and these files are stored in the code's repository. For more information on how {% data variables.product.prodname_actions %} uses YAML, see ["Creating a workflow file](/actions/learn-github-actions/introduction-to-github-actions#create-an-example-workflow)."
|
||||
|
||||
### Custom environment variables
|
||||
### Custom variables
|
||||
|
||||
Travis CI lets you set environment variables and share them between stages. Similarly, {% data variables.product.prodname_actions %} lets you define environment variables for a step, job, or workflow. For more information, see ["Environment variables](/actions/reference/environment-variables)."
|
||||
Travis CI lets you set variables and share them between stages. Similarly, {% data variables.product.prodname_actions %} lets you define variables for a workflows. For more information, see "[Variables](/actions/learn-github-actions/variables)."
|
||||
|
||||
### Default environment variables
|
||||
### Default variables
|
||||
|
||||
Travis CI and {% data variables.product.prodname_actions %} both include default environment variables that you can use in your YAML files. For {% data variables.product.prodname_actions %}, you can see these listed in "[Default environment variables](/actions/reference/environment-variables#default-environment-variables)."
|
||||
Travis CI and {% data variables.product.prodname_actions %} both include default environment variables that you can use in your YAML files. For {% data variables.product.prodname_actions %}, you can see these listed in "[Default environment variables](/actions/learn-github-actions/variables#default-environment-variables)."
|
||||
|
||||
### Parallel job processing
|
||||
|
||||
|
@ -178,7 +178,7 @@ git:
|
|||
|
||||
### Using environment variables in a matrix
|
||||
|
||||
Travis CI and {% data variables.product.prodname_actions %} can both add custom environment variables to a test matrix, which allows you to refer to the variable in a later step.
|
||||
Travis CI and {% data variables.product.prodname_actions %} can both add custom variables to a test matrix, which allows you to refer to the variable in a later step.
|
||||
|
||||
In {% data variables.product.prodname_actions %}, you can use the `include` key to add custom environment variables to a matrix. {% data reusables.actions.matrix-variable-example %}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ versions:
|
|||
|
||||
These extra logs are enabled by setting secrets in the repository containing the workflow, so the same permissions requirements will apply:
|
||||
|
||||
- {% data reusables.actions.permissions-statement-secrets-repository %}
|
||||
- {% data reusables.actions.permissions-statement-secrets-variables-repository %}
|
||||
- {% data reusables.actions.permissions-statement-secrets-environment %}
|
||||
- {% data reusables.actions.permissions-statement-secrets-organization %}
|
||||
- {% data reusables.actions.permissions-statement-secrets-and-variables-organization %}
|
||||
- {% data reusables.actions.permissions-statement-secrets-api %}
|
||||
|
||||
For more information on setting secrets, see "[Creating and using encrypted secrets](/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)."
|
||||
|
|
|
@ -34,7 +34,7 @@ For more information about creating a CI workflow for your Java project with Gra
|
|||
You may also find it helpful to have a basic understanding of the following:
|
||||
|
||||
- "[Working with the npm registry](/packages/working-with-a-github-packages-registry/working-with-the-npm-registry)"
|
||||
- "[Environment variables](/actions/reference/environment-variables)"
|
||||
- "[Variables](/actions/learn-github-actions/variables)"
|
||||
- "[Encrypted secrets](/actions/reference/encrypted-secrets)"
|
||||
- "[Authentication in a workflow](/actions/reference/authentication-in-a-workflow)"
|
||||
|
||||
|
@ -160,10 +160,10 @@ on:
|
|||
types: [created]
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: {% data reusables.actions.action-checkout %}
|
||||
- uses: {% data reusables.actions.action-setup-java %}
|
||||
|
@ -241,10 +241,10 @@ on:
|
|||
types: [created]
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: {% data reusables.actions.action-checkout %}
|
||||
- name: Set up Java
|
||||
|
|
|
@ -34,7 +34,7 @@ For more information about creating a CI workflow for your Java project with Mav
|
|||
You may also find it helpful to have a basic understanding of the following:
|
||||
|
||||
- "[Working with the npm registry](/packages/working-with-a-github-packages-registry/working-with-the-npm-registry)"
|
||||
- "[Environment variables](/actions/reference/environment-variables)"
|
||||
- "[Variables](/actions/learn-github-actions/variables)"
|
||||
- "[Encrypted secrets](/actions/reference/encrypted-secrets)"
|
||||
- "[Authentication in a workflow](/actions/reference/authentication-in-a-workflow)"
|
||||
|
||||
|
@ -142,10 +142,10 @@ on:
|
|||
types: [created]
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: {% data reusables.actions.action-checkout %}
|
||||
- uses: {% data reusables.actions.action-setup-java %}
|
||||
|
@ -179,10 +179,10 @@ on:
|
|||
types: [created]
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: {% data reusables.actions.action-checkout %}
|
||||
- name: Set up Java for publishing to Maven Central Repository
|
||||
|
|
|
@ -35,7 +35,7 @@ For more information about creating a CI workflow for your Node.js project, see
|
|||
You may also find it helpful to have a basic understanding of the following:
|
||||
|
||||
- "[Working with the npm registry](/packages/working-with-a-github-packages-registry/working-with-the-npm-registry)"
|
||||
- "[Environment variables](/actions/reference/environment-variables)"
|
||||
- "[Variables](/actions/learn-github-actions/variables)"
|
||||
- "[Encrypted secrets](/actions/reference/encrypted-secrets)"
|
||||
- "[Authentication in a workflow](/actions/reference/authentication-in-a-workflow)"
|
||||
|
||||
|
@ -128,10 +128,10 @@ on:
|
|||
types: [created]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: {% data reusables.actions.action-checkout %}
|
||||
# Setup .npmrc file to publish to GitHub Packages
|
||||
|
|
|
@ -8,7 +8,7 @@ redirect_from:
|
|||
- /actions/configuring-and-managing-workflows/using-variables-and-secrets-in-a-workflow
|
||||
- /actions/reference/encrypted-secrets
|
||||
- /actions/managing-workflows/storing-secrets
|
||||
|
||||
|
||||
miniTocMaxHeadingLevel: 3
|
||||
versions:
|
||||
fpt: '*'
|
||||
|
@ -22,7 +22,7 @@ versions:
|
|||
|
||||
## About encrypted secrets
|
||||
|
||||
Secrets are encrypted environment variables that you create in an organization, repository, or repository environment. The secrets that you create are available to use in {% data variables.product.prodname_actions %} workflows. {% data variables.product.prodname_dotcom %} uses a [libsodium sealed box](https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes) to help ensure that secrets are encrypted before they reach {% data variables.product.prodname_dotcom %} and remain encrypted until you use them in a workflow.
|
||||
Secrets are encrypted variables that you create in an organization, repository, or repository environment. The secrets that you create are available to use in {% data variables.product.prodname_actions %} workflows. {% data variables.product.prodname_dotcom %} uses a [libsodium sealed box](https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes) to help ensure that secrets are encrypted before they reach {% data variables.product.prodname_dotcom %} and remain encrypted until you use them in a workflow.
|
||||
|
||||
{% data reusables.actions.secrets-org-level-overview %}
|
||||
|
||||
|
@ -40,7 +40,9 @@ For secrets stored at the environment level, you can enable required reviewers t
|
|||
|
||||
### Naming your secrets
|
||||
|
||||
{% data reusables.codespaces.secrets-naming %}
|
||||
The following rules apply to secret names:
|
||||
|
||||
{% data reusables.actions.actions-secrets-and-variables-naming %}
|
||||
|
||||
For example, a secret created at the environment level must have a unique name in that environment, a secret created at the repository level must have a unique name in that repository, and a secret created at the organization level must have a unique name at that level.
|
||||
|
||||
|
@ -72,13 +74,16 @@ When generating credentials, we recommend that you grant the minimum permissions
|
|||
|
||||
## Creating encrypted secrets for a repository
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-repository %}
|
||||
{% data reusables.actions.permissions-statement-secrets-variables-repository %}
|
||||
|
||||
{% webui %}
|
||||
|
||||
{% data reusables.repositories.navigate-to-repo %}
|
||||
{% data reusables.repositories.sidebar-settings %}
|
||||
{% data reusables.actions.sidebar-secret %}
|
||||
{% data reusables.actions.sidebar-secrets-and-variables %}
|
||||
{%- ifversion actions-configuration-variables %}
|
||||
{% data reusables.actions.actions-secrets-tab %}
|
||||
![Repository secrets tab](/assets/images/help/repository/actions-secrets-tab.png){% endif %}
|
||||
1. Click **New repository secret**.
|
||||
1. Type a name for your secret in the **Name** input box.
|
||||
1. Enter the value for your secret.
|
||||
|
@ -143,15 +148,18 @@ gh secret list --env ENV_NAME
|
|||
|
||||
## Creating encrypted secrets for an organization
|
||||
|
||||
When creating a secret in an organization, you can use a policy to limit which repositories can access that secret. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories.
|
||||
{% data reusables.actions.actions-secrets-variables-repository-access %}
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-organization %}
|
||||
{% data reusables.actions.permissions-statement-secrets-and-variables-organization %}
|
||||
|
||||
{% webui %}
|
||||
|
||||
{% data reusables.organizations.navigate-to-org %}
|
||||
{% data reusables.organizations.org_settings %}
|
||||
{% data reusables.actions.sidebar-secret %}
|
||||
{% data reusables.actions.sidebar-secrets-and-variables %}
|
||||
{%- ifversion actions-configuration-variables %}
|
||||
{% data reusables.actions.actions-secrets-tab %}
|
||||
![Organization secrets tab](/assets/images/help/organizations/actions-organization-secrets-tab.png){% endif %}
|
||||
1. Click **New organization secret**.
|
||||
1. Type a name for your secret in the **Name** input box.
|
||||
1. Enter the **Value** for your secret.
|
||||
|
@ -204,9 +212,9 @@ You can check which access policies are being applied to a secret in your organi
|
|||
|
||||
{% data reusables.organizations.navigate-to-org %}
|
||||
{% data reusables.organizations.org_settings %}
|
||||
{% data reusables.actions.sidebar-secret %}
|
||||
{% data reusables.actions.sidebar-secrets-and-variables %}
|
||||
1. The list of secrets includes any configured permissions and policies. For example:
|
||||
![Secrets list](/assets/images/help/settings/actions-org-secrets-list.png)
|
||||
![Secrets list](/assets/images/help/settings/actions-org-secrets-list.png)
|
||||
1. For more details on the configured permissions for each secret, click **Update**.
|
||||
|
||||
## Using encrypted secrets in a workflow
|
||||
|
@ -356,9 +364,9 @@ To use secrets that are larger than 64 KB, you can use a workaround to store enc
|
|||
|
||||
```yaml
|
||||
name: Workflows with large secrets
|
||||
|
||||
|
||||
on: push
|
||||
|
||||
|
||||
jobs:
|
||||
my-job:
|
||||
name: My Job
|
||||
|
@ -399,7 +407,7 @@ You can use Base64 encoding to store small binary blobs as secrets. You can then
|
|||
✓ Set secret CERTIFICATE_BASE64 for octocat/octorepo
|
||||
```
|
||||
|
||||
1. To access the Base64 string from your runner, pipe the secret to `base64 --decode`. For example:
|
||||
1. To access the Base64 string from your runner, pipe the secret to `base64 --decode`. For example:
|
||||
|
||||
```yaml
|
||||
name: Retrieve Base64 secret
|
||||
|
|
|
@ -194,7 +194,7 @@ The list of {% data variables.product.prodname_actions %} IP addresses returned
|
|||
| `workspace` | `GITHUB_WORKSPACE` | Actions and shell commands execute in this directory. An action can modify the contents of this directory, which subsequent actions can access. |
|
||||
| `workflow/event.json` | `GITHUB_EVENT_PATH` | The `POST` payload of the webhook event that triggered the workflow. {% data variables.product.prodname_dotcom %} rewrites this each time an action executes to isolate file content between actions.
|
||||
|
||||
For a list of the environment variables {% data variables.product.prodname_dotcom %} creates for each workflow, see "[Using environment variables](/github/automating-your-workflow-with-github-actions/using-environment-variables)."
|
||||
For a list of the environment variables {% data variables.product.prodname_dotcom %} creates for each workflow, see "[Variables](/actions/learn-github-actions/variables#default-environment-variables)."
|
||||
|
||||
### Docker container filesystem
|
||||
|
||||
|
|
|
@ -87,8 +87,9 @@ Called workflows that are owned by the same user or organization{% ifversion ghe
|
|||
* You can call a maximum of 20 reusable workflows from a single workflow file.
|
||||
{% endif %}
|
||||
{% ifversion private-actions %}{% else %}* Reusable workflows stored within a private repository can only be used by workflows within the same repository.{% endif %}
|
||||
* Any environment variables set in an `env` context defined at the workflow level in the caller workflow are not propagated to the called workflow. For more information about the `env` context, see "[Context and expression syntax for GitHub Actions](/actions/reference/context-and-expression-syntax-for-github-actions#env-context)."{% ifversion actions-reusable-workflow-matrix %}{% else %}
|
||||
* The `strategy` property is not supported in any job that calls a reusable workflow.{% endif %}
|
||||
{% ifversion actions-reusable-workflow-matrix %}{% else %}* The `strategy` property is not supported in any job that calls a reusable workflow.{% endif %}
|
||||
* Any environment variables set in an `env` context defined at the workflow level in the caller workflow are not propagated to the called workflow. For more information, see "[Variables](/actions/learn-github-actions/variables)" and "[Contexts](/actions/learn-github-actions/contexts#env-context)."
|
||||
* To reuse variables in multiple workflows, set them at the organization, repository, or environment levels and reference them using the `vars` context. For more information see "[Variables](/actions/learn-github-actions/variables)" and "[Contexts](/actions/learn-github-actions/contexts#vars-context)."
|
||||
|
||||
## Creating a reusable workflow
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
title: 'Sharing workflows, secrets, and runners with your organization'
|
||||
shortTitle: Share workflows with your organization
|
||||
intro: 'Learn how you can use organization features to collaborate with your team, by sharing starter workflows, secrets, and self-hosted runners.'
|
||||
intro: 'Learn how you can use organization features to collaborate with your team, by sharing starter workflows, secrets,{% ifversion actions-configuration-variables %} variables,{% endif %} and self-hosted runners.'
|
||||
redirect_from:
|
||||
- /actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
- /actions/learn-github-actions/sharing-workflows-secrets-and-runners-with-your-organization
|
||||
|
@ -44,22 +44,28 @@ Your organization can share workflows by reusing the workflows exactly or by cre
|
|||
|
||||
{% data reusables.actions.workflow-organization-templates %} For more information, see "[Creating starter workflows for your organization](/actions/using-workflows/creating-starter-workflows-for-your-organization)."
|
||||
|
||||
## Sharing secrets within an organization
|
||||
## Sharing secrets{% ifversion actions-configuration-variables %} and variables{% endif %} within an organization
|
||||
|
||||
You can centrally manage your secrets within an organization, and then make them available to selected repositories. This also means that you can update a secret in one location, and have the change apply to all repository workflows that use the secret.
|
||||
You can centrally manage your secrets {% ifversion actions-configuration-variables %} and variables{% endif %} within an organization, and then make them available to selected repositories. This also means that you can update a secret {% ifversion actions-configuration-variables %} or variable{% endif %} in one location, and have the change apply to all repository workflows that use the it.
|
||||
|
||||
When creating a secret in an organization, you can use a policy to limit which repositories can access that secret. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories.
|
||||
When creating a secret {% ifversion actions-configuration-variables %} or variable{% endif %} in an organization, you can use a policy to limit which repositories can access it. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories.
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-organization %}
|
||||
{% data reusables.actions.permissions-statement-secrets-and-variables-organization %}
|
||||
|
||||
{% data reusables.organizations.navigate-to-org %}
|
||||
{% data reusables.organizations.org_settings %}
|
||||
{% data reusables.actions.sidebar-secret %}
|
||||
{% data reusables.actions.sidebar-secrets-and-variables %}
|
||||
{%- ifversion actions-configuration-variables %}
|
||||
1. Click the **Secrets** or **Variables** tab, and create the secret or variable with your desired values and options.
|
||||
|
||||
For more information, see "[Creating encrypted secrets for an organization](/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-organization)" or "[Creating configuration variables for an organization](/actions/learn-github-actions/variables#creating-configuration-variables-for-an-organization)."
|
||||
{%- else %}
|
||||
1. Click **New secret**.
|
||||
1. Type a name for your secret in the **Name** input box.
|
||||
1. Enter the **Value** for your secret.
|
||||
1. From the **Repository access** dropdown list, choose an access policy.
|
||||
1. Click **Add secret**.
|
||||
{%- endif %}
|
||||
|
||||
## Share self-hosted runners within an organization
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ The following steps occur to trigger a workflow run:
|
|||
1. {% data variables.product.product_name %} searches the `.github/workflows` directory in your repository for workflow files that are present in the associated commit SHA or Git ref of the event.
|
||||
1. A workflow run is triggered for any workflows that have `on:` values that match the triggering event. Some events also require the workflow file to be present on the default branch of the repository in order to run.
|
||||
|
||||
Each workflow run will use the version of the workflow that is present in the associated commit SHA or Git ref of the event. When a workflow runs, {% data variables.product.product_name %} sets the `GITHUB_SHA` (commit SHA) and `GITHUB_REF` (Git ref) environment variables in the runner environment. For more information, see "[Using environment variables](/actions/automating-your-workflow-with-github-actions/using-environment-variables)."
|
||||
Each workflow run will use the version of the workflow that is present in the associated commit SHA or Git ref of the event. When a workflow runs, {% data variables.product.product_name %} sets the `GITHUB_SHA` (commit SHA) and `GITHUB_REF` (Git ref) environment variables in the runner environment. For more information, see "[Variables](/actions/learn-github-actions/variables)."
|
||||
|
||||
### Triggering a workflow from a workflow
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ A boolean specifying whether the secret must be supplied.
|
|||
|
||||
## `env`
|
||||
|
||||
A `map` of environment variables that are available to the steps of all jobs in the workflow. You can also set environment variables that are only available to the steps of a single job or to a single step. For more information, see [`jobs.<job_id>.env`](#jobsjob_idenv) and [`jobs.<job_id>.steps[*].env`](#jobsjob_idstepsenv).
|
||||
A `map` of variables that are available to the steps of all jobs in the workflow. You can also set variables that are only available to the steps of a single job or to a single step. For more information, see [`jobs.<job_id>.env`](#jobsjob_idenv) and [`jobs.<job_id>.steps[*].env`](#jobsjob_idstepsenv).
|
||||
|
||||
Variables in the `env` map cannot be defined in terms of other variables in the map.
|
||||
|
||||
|
@ -276,7 +276,7 @@ env:
|
|||
|
||||
## `jobs.<job_id>.env`
|
||||
|
||||
A `map` of environment variables that are available to all steps in the job. You can also set environment variables for the entire workflow or an individual step. For more information, see [`env`](#env) and [`jobs.<job_id>.steps[*].env`](#jobsjob_idstepsenv).
|
||||
A `map` of variables that are available to all steps in the job. You can set variables for the entire workflow or an individual step. For more information, see [`env`](#env) and [`jobs.<job_id>.steps[*].env`](#jobsjob_idstepsenv).
|
||||
|
||||
{% data reusables.repositories.actions-env-var-note %}
|
||||
|
||||
|
@ -724,11 +724,11 @@ The `entrypoint` keyword is meant to be used with Docker container actions, but
|
|||
|
||||
### `jobs.<job_id>.steps[*].env`
|
||||
|
||||
Sets environment variables for steps to use in the runner environment. You can also set environment variables for the entire workflow or a job. For more information, see [`env`](#env) and [`jobs.<job_id>.env`](#jobsjob_idenv).
|
||||
Sets variables for steps to use in the runner environment. You can also set variables for the entire workflow or a job. For more information, see [`env`](#env) and [`jobs.<job_id>.env`](#jobsjob_idenv).
|
||||
|
||||
{% data reusables.repositories.actions-env-var-note %}
|
||||
|
||||
Public actions may specify expected environment variables in the README file. If you are setting a secret in an environment variable, you must set secrets using the `secrets` context. For more information, see "[Using environment variables](/actions/automating-your-workflow-with-github-actions/using-environment-variables)" and "[Contexts](/actions/learn-github-actions/contexts)."
|
||||
Public actions may specify expected variables in the README file. If you are setting a secret or sensitive value, such as a password or token, you must set secrets using the `secrets` context. For more information, see "[Contexts](/actions/learn-github-actions/contexts)."
|
||||
|
||||
#### Example
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ shortTitle: Manage encrypted secrets
|
|||
{% data variables.product.prodname_dependabot %} secrets are encrypted credentials that you create at either the organization level or the repository level.
|
||||
When you add a secret at the organization level, you can specify which repositories can access the secret. You can use secrets to allow {% data variables.product.prodname_dependabot %} to update dependencies located in private package registries. When you add a secret it's encrypted before it reaches {% data variables.product.prodname_dotcom %} and it remains encrypted until it's used by {% data variables.product.prodname_dependabot %} to access a private package registry.
|
||||
|
||||
After you add a {% data variables.product.prodname_dependabot %} secret, you can reference it in the _dependabot.yml_ configuration file like this: {% raw %}`${{secrets.NAME}}`{% endraw %}, where "NAME" is the name you chose for the secret. For example:
|
||||
After you add a {% data variables.product.prodname_dependabot %} secret, you can reference it in the _dependabot.yml_ configuration file like this: {% raw %}`${{secrets.NAME}}`{% endraw %}, where "NAME" is the name you chose for the secret. For example:
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
|
@ -45,7 +45,7 @@ The name of a {% data variables.product.prodname_dependabot %} secret:
|
|||
|
||||
## Adding a repository secret for {% data variables.product.prodname_dependabot %}
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-repository %}
|
||||
{% data reusables.repositories.permissions-statement-secrets-repository %}
|
||||
|
||||
{% data reusables.repositories.navigate-to-repo %}
|
||||
{% data reusables.repositories.sidebar-settings %}
|
||||
|
@ -63,7 +63,7 @@ The name of a {% data variables.product.prodname_dependabot %} secret:
|
|||
|
||||
When creating a secret in an organization, you can use a policy to limit which repositories can access that secret. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories.
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-organization %}
|
||||
{% data reusables.organizations.secrets-permissions-statement %}
|
||||
|
||||
{% data reusables.organizations.navigate-to-org %}
|
||||
{% data reusables.organizations.org_settings %}
|
||||
|
@ -75,7 +75,7 @@ When creating a secret in an organization, you can use a policy to limit which r
|
|||
1. If you chose **Selected repositories**:
|
||||
|
||||
* Click {% octicon "gear" aria-label="The Gear icon" %}.
|
||||
* Choose the repositories that can access this secret.
|
||||
* Choose the repositories that can access this secret.
|
||||
![Select repositories for this secret](/assets/images/help/dependabot/secret-repository-access.png)
|
||||
* Click **Update selection**.
|
||||
|
||||
|
@ -84,7 +84,7 @@ When creating a secret in an organization, you can use a policy to limit which r
|
|||
The name of the secret is listed on the Dependabot secrets page. You can click **Update** to change the secret value or its access policy. You can click **Remove** to delete the secret.
|
||||
|
||||
![Update or remove an organization secret](/assets/images/help/dependabot/update-remove-org-secret.png)
|
||||
|
||||
|
||||
## Adding {% data variables.product.prodname_dependabot %} to your registries IP allow list
|
||||
|
||||
If your private registry is configured with an IP allow list, you can find the IP addresses {% data variables.product.prodname_dependabot %} uses to access the registry in the meta API endpoint, under the `dependabot` key. For more information, see "[Meta](/rest/reference/meta)."
|
||||
|
|
|
@ -14,13 +14,13 @@ redirect_from:
|
|||
- /codespaces/managing-codespaces-for-your-organization/managing-encrypted-secrets-for-your-repository-and-organization-for-codespaces
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
## About secrets
|
||||
|
||||
Secrets are encrypted environment variables that you create in an organization or repository. The secrets that you create are available to use in {% data variables.product.prodname_github_codespaces %}. GitHub uses a [libsodium sealed box](https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes) to encrypt secrets before they reach GitHub and only decrypts them when you use them in a codespace.
|
||||
|
||||
Organization-level secrets let you share secrets between multiple repositories, which reduces the need to create duplicate secrets. You can use access policies to control which repositories can use organization secrets.
|
||||
Organization-level secrets let you share secrets between multiple repositories, which reduces the need to create duplicate secrets. You can use access policies to control which repositories can use organization secrets.
|
||||
|
||||
{% data reusables.codespaces.secrets-on-start %}
|
||||
|
||||
|
@ -53,7 +53,7 @@ To create secrets for an organization repository, you must have administrator ac
|
|||
|
||||
When creating a secret in an organization, you can use a policy to limit which repositories can access that secret. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories.
|
||||
|
||||
{% data reusables.actions.permissions-statement-secrets-organization %}
|
||||
{% data reusables.organizations.secrets-permissions-statement %}
|
||||
|
||||
{% data reusables.organizations.navigate-to-org %}
|
||||
{% data reusables.organizations.org_settings %}
|
||||
|
|
|
@ -16,7 +16,7 @@ topics:
|
|||
shortTitle: Encrypted secrets
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## About encrypted secrets for {% data variables.product.prodname_github_codespaces %}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# Reference: #8528
|
||||
# General versioning for Actions configuration variables
|
||||
versions:
|
||||
fpt: '*'
|
||||
ghec: '*'
|
||||
ghes: '>=3.8'
|
|
@ -0,0 +1 @@
|
|||
Contexts are a way to access information about workflow runs, variables, runner environments, jobs, and steps.
|
|
@ -0,0 +1,5 @@
|
|||
* Names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
|
||||
* Names must not start with the `GITHUB_` prefix.
|
||||
* Names must not start with a number.
|
||||
* Names are not case-sensitive.
|
||||
* Names must be unique at the level they are created at.
|
|
@ -0,0 +1 @@
|
|||
1. Click the **Secrets** tab.
|
|
@ -0,0 +1 @@
|
|||
When creating a secret or variable in an organization, you can use a policy to limit access by repository. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories.
|
|
@ -0,0 +1 @@
|
|||
1. Click the **Variables** tab.
|
|
@ -0,0 +1,36 @@
|
|||
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 %}
|
|
@ -0,0 +1,5 @@
|
|||
{% note %}
|
||||
|
||||
**Note:** Configuration variables for {% data variables.product.prodname_actions %} are in beta and subject to change.
|
||||
|
||||
{% endnote %}
|
|
@ -0,0 +1 @@
|
|||
To create secrets {% ifversion actions-configuration-variables %}or variables {% endif %}at the organization level, you must have `admin` access.
|
|
@ -1 +1 @@
|
|||
To create secrets for an environment in a personal account repository, you must be the repository owner. To create secrets for an environment in an organization repository, you must have `admin` access.
|
||||
To create secrets {% ifversion actions-configuration-variables %}or variables {% endif %}for an environment in a personal account repository, you must be the repository owner. To create secrets {% ifversion actions-configuration-variables %}or variables {% endif %}for an environment in an organization repository, you must have `admin` access.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
To create secrets {% ifversion actions-configuration-variables %}or variables {% endif %}for a personal account repository, you must be the repository owner. To create secrets {% ifversion actions-configuration-variables %}or variables {% endif %}for an organization repository, you must have `admin` access.
|
|
@ -1,5 +0,0 @@
|
|||
{% ifversion fpt or ghec or ghes > 3.4 or ghae > 3.4 -%}
|
||||
1. In the "Security" section of the sidebar, select **{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets**, then click **Actions**.
|
||||
{%- else %}
|
||||
1. In the left sidebar, click **Secrets**.
|
||||
{%- endif %}
|
|
@ -0,0 +1,5 @@
|
|||
{% ifversion fpt or ghec or ghes > 3.4 or ghae > 3.4 -%}
|
||||
1. In the "Security" section of the sidebar, select {% ifversion actions-configuration-variables %}**{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets and variables**, {% else %}**{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets**, {% endif %}then click **Actions**.
|
||||
{%- else %}
|
||||
1. In the left sidebar, click **Secrets**.
|
||||
{%- endif %}
|
|
@ -1,9 +1,9 @@
|
|||
{% data variables.product.prodname_actions %} includes a collection of variables called _contexts_ and a similar collection of variables called _default environment variables_. These variables are intended for use at different points in the workflow:
|
||||
{% data variables.product.prodname_actions %} includes a collection of variables called _contexts_ and a similar collection of variables called _default variables_. These variables are intended for use at different points in the workflow:
|
||||
|
||||
- **Default environment variables:** These variables exist only on the runner that is executing your job. For more information, see "[Default environment variables](/actions/reference/environment-variables#default-environment-variables)."
|
||||
- **Contexts:** You can use most contexts at any point in your workflow, including when _default environment variables_ would be unavailable. For example, you can use contexts with expressions to perform initial processing before the job is routed to a runner for execution; this allows you to use a context with the conditional `if` keyword to determine whether a step should run. Once the job is running, you can also retrieve context variables from the runner that is executing the job, such as `runner.os`. For details of where you can use various contexts within a workflow, see "[Context availability](/actions/reference/context-and-expression-syntax-for-github-actions#context-availability)."
|
||||
- **Default environment variables:** These environment variables exist only on the runner that is executing your job. For more information, see "[Default environment variables](/actions/learn-github-actions/variables#default-environment-variables)."
|
||||
- **Contexts:** You can use most contexts at any point in your workflow, including when _default variables_ would be unavailable. For example, you can use contexts with expressions to perform initial processing before the job is routed to a runner for execution; this allows you to use a context with the conditional `if` keyword to determine whether a step should run. Once the job is running, you can also retrieve context variables from the runner that is executing the job, such as `runner.os`. For details of where you can use various contexts within a workflow, see "[Context availability](/actions/reference/context-and-expression-syntax-for-github-actions#context-availability)."
|
||||
|
||||
The following example demonstrates how these different types of environment variables can be used together in a job:
|
||||
The following example demonstrates how these different types of variables can be used together in a job:
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
|
@ -18,4 +18,4 @@ jobs:
|
|||
```
|
||||
{% endraw %}
|
||||
|
||||
In this example, the `if` statement checks the [`github.ref`](/actions/reference/context-and-expression-syntax-for-github-actions#github-context) context to determine the current branch name; if the name is `refs/heads/main`, then the subsequent steps are executed. The `if` check is processed by {% data variables.product.prodname_actions %}, and the job is only sent to the runner if the result is `true`. Once the job is sent to the runner, the step is executed and refers to the [`$GITHUB_REF`](/actions/reference/environment-variables#default-environment-variables) environment variable from the runner.
|
||||
In this example, the `if` statement checks the [`github.ref`](/actions/reference/context-and-expression-syntax-for-github-actions#github-context) context to determine the current branch name; if the name is `refs/heads/main`, then the subsequent steps are executed. The `if` check is processed by {% data variables.product.prodname_actions %}, and the job is only sent to the runner if the result is `true`. Once the job is sent to the runner, the step is executed and refers to the [`$GITHUB_REF`](/actions/learn-github-actions/variables#default-environment-variables) variable from the runner.
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
1. In the **Name** field, enter a name for your variable.
|
||||
1. In the **Value** field, enter the value for your variable.
|
|
@ -4,4 +4,4 @@ The following rules apply to secret names:
|
|||
* Secret names must not start with the `GITHUB_` prefix.
|
||||
* Secret names must not start with a number.
|
||||
* Secret names are not case-sensitive.
|
||||
* Secret names must be unique at the level they are created at.
|
||||
* Secret names must be unique at the level they are created at.
|
|
@ -1 +1 @@
|
|||
1. In the "Security" section of the sidebar, select **{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets**, then click **{% data variables.product.prodname_codespaces %}**.
|
||||
1. In the "Security" section of the sidebar, select {% ifversion actions-configuration-variables %}**{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets and variables**, {% else %}**{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets**, {% endif %}then click **{% data variables.product.prodname_codespaces %}**.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% ifversion fpt or ghec or ghes > 3.4 or ghae > 3.4 %}
|
||||
1. In the "Security" section of the sidebar, select **{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets**, then click **{% data variables.product.prodname_dependabot %}**.
|
||||
1. In the "Security" section of the sidebar, select {% ifversion actions-configuration-variables %}**{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets and variables**, {% else %}**{% octicon "key-asterisk" aria-label="The key-asterisk icon" %} Secrets**, {% endif %}then click **{% data variables.product.prodname_dependabot %}**.
|
||||
{% else %}
|
||||
1. In the sidebar, click **{% data variables.product.prodname_dependabot %}**.
|
||||
![{% data variables.product.prodname_dependabot %} secrets sidebar option](/assets/images/enterprise/3.3/dependabot/dependabot-secrets.png)
|
||||
|
|
|
@ -1 +1 @@
|
|||
To create secrets at the organization level, you must have `admin` access.
|
||||
To create secrets at the organization level, you must have `admin` access.
|
|
@ -1 +1 @@
|
|||
When more than one environment variable is defined with the same name, {% data variables.product.prodname_dotcom %} uses the most specific environment variable. For example, an environment variable defined in a step will override job and workflow variables with the same name, while the step executes. A variable defined for a job will override a workflow variable with the same name, while the job executes.
|
||||
When more than one environment variable is defined with the same name, {% data variables.product.prodname_dotcom %} uses the most specific variable. For example, an environment variable defined in a step will override job and workflow environment variables with the same name, while the step executes. An environment variable defined for a job will override a workflow variable with the same name, while the job executes.
|
||||
|
|
Загрузка…
Ссылка в новой задаче