Home > Development Tools > git > body text

how to export variable in github actions

Mary-Kate Olsen
Release: 2024-10-10 11:41:14
Original
425 people have browsed it

This article provides a comprehensive guide on managing environment variables within GitHub actions. It discusses two methods: exporting variables using the "export" keyword and defining outputs using the "outputs" keyword. The gu

how to export variable in github actions

How to export an environment variable from a GitHub action?

To export an environment variable from a GitHub action, you can use the export keyword. The syntax for exporting a variable is as follows:

<code class="yaml">export variable_name=variable_value</code>
Copy after login
Copy after login

For example, the following action exports the MY_VARIABLE environment variable with the value my-value:

<code class="yaml">steps:
  - export MY_VARIABLE=my-value</code>
Copy after login

How can I make a variable available outside of a GitHub action?

To make a variable available outside of a GitHub action, you can use the outputs keyword. The syntax for defining outputs is as follows:

<code class="yaml">outputs:
  variable_name:
    value: variable_value</code>
Copy after login

For example, the following action defines the MY_VARIABLE output with the value my-value:

<code class="yaml">outputs:
  MY_VARIABLE:
    value: my-value</code>
Copy after login

What is the syntax for exporting a variable in GitHub actions?

The syntax for exporting a variable in GitHub actions is as follows:

<code class="yaml">export variable_name=variable_value</code>
Copy after login
Copy after login

The above is the detailed content of how to export variable in github actions. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template