how to set output in github actions

This guide explains how to set output variables in GitHub Actions using the set-output action. It covers setting a single output variable, multiple output variables in a single action, and accessing output variables set by other jobs.

how to set output in github actions

How do I set output variables in GitHub Actions?

You can set output variables in GitHub Actions using the set-output action. This action allows you to set a single output variable at a time. The syntax for the set-output action is as follows:

<code class="yaml">- set-output:
name: name-of-output-variable
value: value-of-output-variable</code>

For example, the following action will set an output variable called my-output-variable with the value my-output-value:

<code class="yaml">- set-output:
name: my-output-variable
value: my-output-value</code>

Can I set multiple output variables in a single GitHub Action?

Yes, you can set multiple output variables in a single GitHub Action by using multiple set-output actions. For example, the following action will set two output variables: my-output-variable1 with the value my-output-value1 and my-output-variable2 with the value my-output-value2:

<code class="yaml">- set-output:
name: my-output-variable1
value: my-output-value1
- set-output:
name: my-output-variable2
value: my-output-value2</code>

How do I access output variables set by other jobs in GitHub Actions?

You can access output variables set by other jobs in GitHub Actions by using the jobs.<job_name>.outputs.<output_variable_name> syntax. For example, the following action will access the my-output-variable output variable set by the my-job job:

<code class="yaml">- echo: ${{ jobs.my-job.outputs.my-output-variable }}</code>

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

原文来自:www.php.cn
© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容