How to create a virtual environment with github actions that can be used by other jobs at the same yaml file?

huangapple go评论59阅读模式
英文:

How to create a virtual environment with github actions that can be used by other jobs at the same yaml file?

问题

我正在尝试创建 Python 虚拟环境,但在任务完成后它就“死了”,而我想在其他任务中使用这个虚拟环境。我应该怎么做?

我考虑使用缓存,但对于这个选项我了解不够。

英文:

I'm trying to create python venv, but it's "dead" when the job is finished, and I want to use the venv in other jobs. What should I do?

I thought of using cache, but I'm not familiar enough with this option.

答案1

得分: 1

你可以使用工作流程工件将数据从一个作业传递到下一个

      - name: 存档代码覆盖率结果
        uses: actions/upload-artifact@v3
        with:
          name: venv
          path: .venv

然后确保将来的作业在创建工件的作业上声明 needs:

然后使用 download-artifact 再次下载:

- name: 下载单个工件
  uses: actions/download-artifact@v3
  with:
    name: venv
英文:

You can use workflow artifacts to carry data from one job to the next.

      - name: Archive code coverage results
        uses: actions/upload-artifact@v3
        with:
          name: venv
          path: .venv

Then make sure the future jobs declare a needs: on the job that created the artifact.

And download it again with download-artifact:

- name: Download a single artifact
  uses: actions/download-artifact@v3
  with:
    name: venv

huangapple
  • 本文由 发表于 2023年3月12日 16:28:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75711893.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定