【问题标题】:What does ubuntu-latest mean for GitHub Actions?ubuntu-latest 对 GitHub Actions 意味着什么?
【发布时间】:2021-12-18 18:25:47
【问题描述】:

今天我正在处理 Github Actions 的主题。我对CI这个话题不熟悉。

在 GitHub,我想创建一个操作。目前我使用 GitHub 的样板。我不明白 ubuntu-latest jobs: build: runs-on: ubuntu-latest 是什么意思。在另一个教程中,我看到了自托管。在我要部署的服务器上也是ubuntu,不过这和它无关吧?

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

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


    【解决方案1】:

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

    GitHub Actions 在hosted virtual environments 中使用,也可以在自己的环境中使用self-host the runner

    基本上,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):

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

    【讨论】:

    • 感谢@GuiFalourd 的好回答。所以它有点像你用来构建应用程序的 DockerContainer。那么使用与我的服务器(Ubuntu-18)相同的环境是有意义的,对吧?一旦操作成功,我就知道应用程序将在我的服务器上运行,然后可以触发部署到我的服务器。
    • 请注意,如果您愿意,您也可以在跑步者中使用 docker 映像,Github Actions 已经支持这一点。
    • 如果您愿意,可以使用与服务器上相同的环境??
    猜你喜欢
    • 1970-01-01
    • 2011-12-28
    • 2020-10-12
    • 2011-06-11
    • 2010-10-02
    • 2013-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多