Skip to main content

此版本的 GitHub Enterprise Server 已于以下日期停止服务 2024-03-26. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

使用 GitHub Actions 导入工具自动迁移

使用 GitHub Actions Importer 规划和自动迁移到 GitHub Actions。

注意:GitHub Enterprise Server 目前不支持 GitHub 托管的运行器。 可以在 GitHub public roadmap 上查看有关未来支持计划的更多信息。

法律通告

关于 GitHub Actions Importer

可以使用 GitHub Actions Importer 来规划 CI/CD 支持的管道并将其自动迁移到 GitHub Actions。

GitHub Actions Importer 以 Docker 容器形式分发,并使用 GitHub CLI 扩展与容器交互。

应先检查 GitHub Actions Importer 转换的任何工作流的正确性,然后才能将其用作生产工作负载。 目标是为每个工作流实现 80% 的转换率,但是,实际转换率将取决于转换的每个单独管道的构成。

支持的 CI 平台

可以使用 GitHub Actions Importer 从以下平台进行迁移:

  • Azure DevOps
  • Bamboo
  • Bitbucket 管道
  • CircleCI
  • GitLab
  • Jenkins
  • Travis CI

先决条件

GitHub Actions Importer 具有以下要求:

  • 一个可在其中运行基于 Linux 的容器并可安装所需工具的环境。

    注意:GitHub Actions Importer 容器和 CLI 不需要安装在 CI 平台所在的同一服务器上。

安装 GitHub Actions Importer CLI 扩展

  1. 安装 GitHub Actions Importer CLI 扩展:

    Bash
    gh extension install github/gh-actions-importer
    
  2. 验证是否已安装扩展:

    $ gh actions-importer -h
    Options:
      -?, -h, --help  Show help and usage information
    
    Commands:
      update     Update to the latest version of GitHub Actions Importer.
      version    Display the version of GitHub Actions Importer.
      configure  Start an interactive prompt to configure credentials used to authenticate with your CI server(s).
      audit      Plan your CI/CD migration by analyzing your current CI/CD footprint.
      forecast   Forecast GitHub Actions usage from historical pipeline utilization.
      dry-run    Convert a pipeline to a GitHub Actions workflow and output its yaml file.
      migrate    Convert a pipeline to a GitHub Actions workflow and open a pull request with the changes.
    

更新 GitHub Actions Importer CLI

若要确保运行最新版本的 GitHub Actions Importer,应定期运行 update 命令:

gh actions-importer update

在命令行进行身份验证

必须配置可支持 GitHub Actions Importer 与 GitHub 及当前 CI 服务器进行通信的凭据。 可以使用环境变量或 .env.local 文件配置这些凭据。 可以通过运行以下命令在交互式提示中配置环境变量:

gh actions-importer configure

使用 GitHub Actions Importer CLI

使用 gh actions-importer 的子命令开始迁移到 GitHub Actions,包括 auditforecastdry-runmigrate

审核现有 CI 管道

audit 子命令可用于通过分析当前的 CI/CD 内存占用情况来规划 CI/CD 迁移。 此分析可用于规划迁移到 GitHub Actions 的时间线。

若要运行审核,请使用以下命令确定可用选项:

$ gh actions-importer audit -h
Description:
  Plan your CI/CD migration by analyzing your current CI/CD footprint.

[...]

Commands:
  azure-devops  An audit will output a list of data used in an Azure DevOps instance.
  bamboo        An audit will output a list of data used in a Bamboo instance.
  circle-ci     An audit will output a list of data used in a CircleCI instance.
  gitlab        An audit will output a list of data used in a GitLab instance.
  jenkins       An audit will output a list of data used in a Jenkins instance.
  travis-ci     An audit will output a list of data used in a Travis CI instance.

预测使用情况

forecast 子命令查看历史管道使用情况,以创建 GitHub Actions 使用情况的预测。

若要运行预测,请使用以下命令确定可用选项:

$ gh actions-importer forecast -h
Description:
  Forecasts GitHub Actions usage from historical pipeline utilization.

[...]

Commands:
  azure-devops  Forecasts GitHub Actions usage from historical Azure DevOps pipeline utilization.
  bamboo        Forecasts GitHub Actions usage from historical Bamboo pipeline utilization.
  jenkins       Forecasts GitHub Actions usage from historical Jenkins pipeline utilization.
  gitlab        Forecasts GitHub Actions usage from historical GitLab pipeline utilization.
  circle-ci     Forecasts GitHub Actions usage from historical CircleCI pipeline utilization.
  travis-ci     Forecasts GitHub Actions usage from historical Travis CI pipeline utilization.
  github        Forecasts GitHub Actions usage from historical GitHub pipeline utilization.

测试迁移过程

dry-run 子命令可用于将管道转换为其 GitHub Actions 等效项,然后将工作流写入本地文件系统。

若要执行试运行,请使用以下命令确定可用选项:

$ gh actions-importer dry-run -h
Description:
  Convert a pipeline to a GitHub Actions workflow and output its yaml file.

[...]

Commands:
  azure-devops  Convert an Azure DevOps pipeline to a GitHub Actions workflow and output its yaml file.
  bamboo        Convert a Bamboo pipeline to GitHub Actions workflows and output its yaml file.
  circle-ci     Convert a CircleCI pipeline to GitHub Actions workflows and output the yaml file(s).
  gitlab        Convert a GitLab pipeline to a GitHub Actions workflow and output the yaml file.
  jenkins       Convert a Jenkins job to a GitHub Actions workflow and output its yaml file.
  travis-ci     Convert a Travis CI pipeline to a GitHub Actions workflow and output its yaml file.

将管道迁移到 GitHub Actions

migrate 子命令可用于将管道转换为其 GitHub Actions 等效项,然后使用内容创建拉取请求。

若要运行迁移,请使用以下命令确定可用选项:

$ gh actions-importer migrate -h
Description:
  Convert a pipeline to a GitHub Actions workflow and open a pull request with the changes.

[...]

Commands:
  azure-devops  Convert an Azure DevOps pipeline to a GitHub Actions workflow and open a pull request with the changes.
  bamboo        Convert a Bamboo pipeline to GitHub Actions workflows and open a pull request with the changes.
  circle-ci     Convert a CircleCI pipeline to GitHub Actions workflows and open a pull request with the changes.
  gitlab        Convert a GitLab pipeline to a GitHub Actions workflow and open a pull request with the changes.
  jenkins       Convert a Jenkins job to a GitHub Actions workflow and open a pull request with the changes.
  travis-ci     Convert a Travis CI pipeline to a GitHub Actions workflow and and open a pull request with the changes.

使用 IssueOps 执行自助迁移

可以使用 GitHub Actions 和 GitHub Issues 为 GitHub Actions Importer 运行 CLI 命令。 这样,无需在本地计算机上安装软件即可迁移 CI/CD 工作流。 对于想要启用到 GitHub Actions 的自助迁移的组织,此方法特别有用。 配置 IssueOps 后,用户可以通过相关模板创建问题,将管道迁移到 GitHub Actions。

有关使用 IssueOps 设置自助迁移的详细信息,请参阅 actions/importer-issue-ops 模板存储库。

使用 GitHub Actions Importer 实验室存储库

GitHub Actions Importer 实验室存储库包含特定于平台的学习路径,可以指导你如何使用 GitHub Actions Importer 以及如何处理到 GitHub Actions 的迁移。 可以使用此存储库了解如何使用 GitHub Actions Importer 来帮助计划、预测和自动迁移到 GitHub Actions。

有关详细信息,请参阅 GitHub Actions 导入程序实验室存储库

部分内容改编自 MIT 许可证下的 https://github.com/github/gh-actions-importer/

MIT License

Copyright (c) 2022 GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.