根据 GitHub 最近的公告,github 行动的set-output
明年将被弃用。我能够使用新格式(echo "{name}={value}" >> $GITHUB_OUTPUT
)在工作流程文件中,它可以工作。但我们也有一个用 python 编写的自定义 GitHub 操作(私有操作)我们也在使用set-output
在那里main.py
as:
output_matrix = json.dumps(jsondata)
print(f"::set-output name=output_matrix::{output_matrix}")
到目前为止我尝试过的是:
print(f"output_matrix = {output_matrix} >> $GITHUB_OUTPUT")
但这似乎没有帮助。我们如何使用任何解决方案set-output
自定义 github 操作 python 文件中的新格式。
我做了一个测试here https://github.com/GuillaumeFalourd/poc-github-actions/actions/runs/3282142781/jobs/5405134970使用这个工作流程实施 https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/workflow-tester64.yml和这个蟒蛇脚本 https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/new-output.py.
你可以做什么蟒蛇脚本输出变量的实现与环境变量的实现相同。
环境变量示例: (这是关于它的另一个主题 https://stackoverflow.com/questions/70123328/how-to-set-environment-variables-in-github-actions-using-python)
import os
env_file = os.getenv('GITHUB_ENV')
hello='hello'
with open(env_file, "a") as myfile:
myfile.write(f"TEST={hello}")
输出变量的示例:
import os
output_file = os.getenv('GITHUB_OUTPUT')
hello='hello'
with open(output_file, "a") as myfile:
myfile.write(f"TEST={hello}")
请注意,该实现甚至在有关更新之前就可以运行::set-output
折旧。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)