python - 可以直接在action.yml文件的 "run | "段下写Python代码吗

标签 python github-actions building-github-actions

在GitHub Actions中,可以直接在run | 下写python代码吗? -部分在action.yml文件?
我可以用 Python 编写 GitHub Actions 脚本吗?

最佳答案

有一个built-in shell keyword对于 python 。

steps:
  - name: Display the path
    run: |
      import os
      print(os.environ['PATH'])
    shell: python
来源:https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-running-a-python-script

您也可以使用 custom shell . GitHub Actions 写入 run 的值到一个临时文件并通过替换 {0} 将其传递给指定的 shell带有临时脚本的文件名。
steps:
  - name: Display the path
    run: |
      import os
      print(os.environ['PATH'])
    shell: python {0}

关于python - 可以直接在action.yml文件的 "run | "段下写Python代码吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66688483/

相关文章:

python 按键访问字典

Python Spacy 相似性没有循环?

node.js - github-actions 如何在(生产)构建结果而不是开发模式上运行测试

python - 使用字符串作为变量名

python setup.py : install either tensorflow or tensorflow-gpu?

git - 在 Github Actions 中克隆私有(private)仓库

node.js - 运行单元测试管道时 Github 操作错误

npm - Github 操作 : NPM publish 404 not found

github-actions - 如何确定触发当前工作流程的 Github Actions 事件是否是新的拉取请求?

c++ - 由于找不到conanfile.py,使用CMake,conan和Vulkan SDK的Github操作失败