当我创建 GitHub 操作工作流文件时,示例 YAML 文件包含 runs-on: ubuntu-latest
. According to the docs ,我只能在几个版本的 Ubuntu、Windows Server 和 macOS X 之间进行选择。
我认为 GitHub Actions 在 Docker 中运行。如何选择我的 Docker 镜像?
最佳答案
GitHub 操作提供了一个虚拟机——正如你所指出的,无论是 Ubuntu、Windows 还是 macOS——并在其中运行你的工作流程。然后,您可以使用该虚拟机在容器内运行工作流。
使用 the container
specifier在容器内运行一个步骤。请务必指定 runs-on
作为容器的适当主机环境(ubuntu-latest
用于 Linux 容器,windows-latest
用于 Windows 容器)。例如:
jobs:
vm:
runs-on: ubuntu-latest
steps:
- run: |
echo This job does not specify a container.
echo It runs directly on the virtual machine.
name: Run on VM
container:
runs-on: ubuntu-latest
container: node:10.16-jessie
steps:
- run: |
echo This job does specify a container.
echo It runs in the container instead of the VM.
name: Run in container
关于docker - 如何将 Docker 与 GitHub Actions 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57549439/