Skip to main content

Automatización de la migración con el Importador de Acciones de GitHub

Usa el GitHub Actions Importer para planificar y automatizar la migración a GitHub Actions.

Aviso legal

Acerca del GitHub Actions Importer

Puede usar el GitHub Actions Importer para planificar las canalizaciones admitidasde CI/CD y migrarlas automáticamente a GitHub Actions.

El GitHub Actions Importer se distribuye como contenedor Docker y usa una extensión de la CLI de GitHub para interactuar con el contenedor.

Cualquier flujo de trabajo que el GitHub Actions Importer haya convertido debe inspeccionarse para comprobar si es correcto antes de usarlo como una carga de trabajo de producción. El objetivo es lograr una tasa de conversión del 80 % para cada flujo de trabajo. Sin embargo, la tasa de conversión real dependerá de la composición de cada canalización individual que se convierta.

Plataformas de CI compatibles

Puedes usar el GitHub Actions Importer para migrar desde las plataformas siguientes:

  • Azure DevOps
  • Bamboo
  • Bitbucket Pipelines
  • CircleCI
  • GitLab
  • Jenkins
  • Travis CI

Requisitos previos

El GitHub Actions Importer tiene los requisitos siguientes:

  • Un entorno en el que puedas ejecutar contenedores basados en Linux e instalar las herramientas necesarias.

    Nota: El contenedor y la CLI del GitHub Actions Importer no deben estar instalados en el mismo servidor que tu plataforma de CI.

Instalación de la extensión de la CLI del GitHub Actions Importer

  1. Instala la extensión de la CLI del GitHub Actions Importer:

    Bash
    gh extension install github/gh-actions-importer
    
  2. Comprueba que la extensión está instalada:

    $ 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.
    

Actualización de la CLI del GitHub Actions Importer

Para asegurarte de que ejecutas la versión más reciente del GitHub Actions Importer, debes ejecutar periódicamente el comando update:

gh actions-importer update

Autenticación en la línea de comandos

Debes configurar credenciales que permitan que el GitHub Actions Importer se comunique con GitHub y el servidor de CI actual. Puedes usar variables de entorno o un archivo .env.local para configurar estas credenciales. Las variables de entorno se pueden configurar en un símbolo del sistema interactivo mediante la ejecución del comando siguiente:

gh actions-importer configure

Uso de la CLI del GitHub Actions Importer

Usa los subcomandos de gh actions-importer para iniciar la migración a GitHub Actions, incluidos audit, forecast, dry-run y migrate.

Auditoría de las canalizaciones de CI existentes

El subcomando audit se puede usar para planificar la migración de CI/CD mediante el análisis de la superficie actual de CI/CD. Este análisis se puede usar para planificar una escala de tiempo para migrar a GitHub Actions.

Para ejecutar una auditoría, usa el siguiente comando para determinar las opciones disponibles:

$ 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.

Previsión de la utilización

El subcomando forecast revisa la utilización histórica de la canalización para crear una previsión de la utilización de GitHub Actions.

Para ejecutar una previsión, usa el siguiente comando para determinar las opciones disponibles:

$ 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.

Prueba del proceso de migración

El subcomando dry-run se puede usar para convertir una canalización en su equivalente de GitHub Actions y, a continuación, escribir el flujo de trabajo en el sistema de archivos local.

Para realizar un simulacro, usa el siguiente comando para determinar las opciones disponibles:

$ 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.

Migración de una canalización a GitHub Actions

El subcomando migrate se puede usar para convertir una canalización en su equivalente de Acciones de GitHub y, a continuación, crear una solicitud de incorporación de cambios con el contenido.

Para ejecutar una migración, usa el siguiente comando para determinar las opciones disponibles:

$ 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.

Realización de migraciones de autoservicio mediante IssueOps

Puede usar GitHub Actions y GitHub Issues a fin de ejecutar comandos de la CLI para GitHub Actions Importer. Esto te permite migrar los flujos de trabajo de CI/CD sin instalar software en el equipo local. Este enfoque es especialmente útil para las organizaciones que quieren habilitar migraciones de autoservicio a GitHub Actions. Una vez que se configura IssueOps, los usuarios pueden abrir una incidencia con la plantilla pertinente para migrar canalizaciones a GitHub Actions.

Para más información sobre cómo configurar migraciones de autoservicio con IssueOps, consulta el repositorio de plantillas actions/importer-issue-ops.

Uso del repositorio de laboratorios de GitHub Actions Importer

El repositorio de laboratorios de GitHub Actions Importer contiene rutas de aprendizaje específicas de la plataforma en las que se enseña cómo usar GitHub Actions Importer y cómo abordar las migraciones a GitHub Actions. Puedes utilizar este repositorio para aprender a usar GitHub Actions Importer para ayudar a planear, predecir y automatizar la migración a GitHub Actions.

Para más información, consulta el repositorio de laboratorios Importer de Acciones de GitHub.

Algunas partes se han adaptado a partir de https://github.com/github/gh-actions-importer/ con licencia MIT:

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.