ubuntu-latest 对于 GitHub Actions 意味着什么?

问题描述 投票:0回答:3

今天我要讨论的话题是Github Actions。我对 CI 的话题不太熟悉。

在 GitHub 我想创建一个操作。我暂时使用GitHub的样板。我不明白 ubuntu-latest

jobs: build: runs-on: ubuntu-latest
是什么意思。在另一个教程中我看到了自托管。我要部署的服务器上也是ubuntu,但是那跟它没关系吧?

非常感谢您的回答、反馈、评论和想法。

GitHub 工作流程 yml

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: echo Hello, world!

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
continuous-integration github-actions
3个回答
25
投票

runner
是从 GitHub Actions 工作流程运行作业及其步骤的应用程序。

它由 GitHub Actions 在托管虚拟环境中使用,或者您可以在自己的环境中自行托管运行器

基本上,GitHub 托管的运行程序提供了一种更快、更简单的方式来运行工作流程,而自托管运行程序是一种在您自己的自定义环境中运行工作流程的高度可配置的方式。

引用Github文档:

GitHub-hosted runners:

- Receive automatic updates for the operating system, preinstalled packages and tools, and the self-hosted runner application.
- Are managed and maintained by GitHub.
- Provide a clean instance for every job execution.
- Use free minutes on your GitHub plan, with per-minute rates applied after surpassing the free minutes.

Self-hosted runners:

- Receive automatic updates for the self-hosted runner application only. You are responsible for updating the operating system and all other software.
- Can use cloud services or local machines that you already pay for.
- Are customizable to your hardware, operating system, software, and security requirements.
- Don't need to have a clean instance for every job execution.
Are free to use with GitHub Actions, but you are responsible for the cost of maintaining your runner machines.

您还可以在上面共享的链接上看到下表,其中显示了可用的 Github 托管运行器及其相关标签(例如

ubuntu-latest
):

enter image description here

因此,当您告知

ubuntu-latest
您的工作流程时,您要求Github提供一个运行器来执行您的作业实现中包含的所有步骤(它与您希望部署的服务器无关,而是与将执行该任务的管道相关)部署操作(在您的情况下)。


6
投票

ubuntu-latest
指的是最新版本的ubuntu(Linux操作系统)的镜像,可用于运行GitHuB Actions。它预装了很多其他软件并可供使用。存储库上有该图像的完整列表(例如此处)。

您还可以通过在 GitHub Action 中运行 this 来列出自己预装的软件包:

apt list --installed

这将产生此列表(下面的缩短版本,完整列表此处):

Listing...
acl/jammy,now 2.3.1-1 amd64 [installed]
adduser/jammy,now 3.118ubuntu5 all [installed,automatic]
adoptium-ca-certificates/now 1.0.1-1 all [installed,local]
adwaita-icon-theme/jammy,now 41.0-1ubuntu1 all [installed,automatic]
alsa-topology-conf/jammy,now 1.2.5.1-2 all [installed,automatic]
alsa-ucm-conf/jammy-updates,now 1.2.6.3-1ubuntu1.4 all [installed,automatic]
ant-optional/jammy,now 1.10.12-1 all [installed]
ant/jammy,now 1.10.12-1 all [installed]
apache2-bin/jammy-updates,jammy-security,now 2.4.52-1ubuntu4.4 amd64 [installed,automatic]
...
...
...
zip/jammy,now 3.0-12build2 amd64 [installed]
zlib1g-dev/jammy-updates,jammy-security,now 1:1.2.11.dfsg-2ubuntu9.2 amd64 [installed]
zlib1g/jammy-updates,jammy-security,now 1:1.2.11.dfsg-2ubuntu9.2 amd64 [installed,automatic]
zstd/jammy,now 1.4.8+dfsg-3build1 amd64 [installed,automatic]
zsync/jammy,now 0.6.2-3ubuntu1 amd64 [installed]

0
投票

当我们运行管道时,ubuntu 服务器位于哪里? GitHub 是否使用 Microsoft Azure 来执行此任务来创建 Ubuntu 服务器的虚拟机?

© www.soinside.com 2019 - 2024. All rights reserved.