Skip to main content

Automatizar a migração com o Importador do Actions

Aviso legal

Você pode usar Actions Importer para planejar e migrar automaticamente seus pipelines compatíveis com CI/CD para Actions.

O Actions Importer é distribuído como um contêiner do Docker e usa uma extensão da CLI do para interagir com o contêiner.

Qualquer fluxo de trabalho convertido pelo Actions Importer deve ser inspecionado quanto à exatidão antes de ser usado como uma carga de trabalho de produção. A meta é alcançar uma taxa de conversão de 80% para cada fluxo de trabalho, no entanto, a taxa de conversão real dependerá da composição de cada pipeline individual convertido.

É possível usar o Actions Importer para migrar das seguintes plataformas:

  • Azure DevOps
  • Bamboo
  • Bitbucket Pipelines
  • CircleCI
  • GitLab (nuvem e auto-hospedado)
  • Jenkins
  • Travis CI

O Actions Importer tem os seguintes requisitos:

  • Um ambiente em que seja possível executar contêineres baseados no Linux e instalar as ferramentas necessárias.

    Observação

    A CLI e o contêiner do Actions Importer não precisam ser instalados no mesmo servidor que a plataforma de CI.

  1. Instale a extensão da CLI do Actions Importer:

    Bash
    gh extension install /gh-actions-importer
    
  2. Verifique se a extensão foi instalada:

    $ gh actions-importer -h
    Options:
      -?, -h, --help  Show help and usage information
    
    Commands:
      update     Update to the latest version of  Actions Importer.
      version    Display the version of  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  Actions usage from historical pipeline utilization.
      dry-run    Convert a pipeline to a  Actions workflow and output its yaml file.
      migrate    Convert a pipeline to a  Actions workflow and open a pull request with the changes.
    

Execute regularmente o comando update para garantir que você esteja executando a versão mais recente do Actions Importer:

gh actions-importer update

Você deve configurar credenciais para permitir que o Actions Importer se comunique com o e com seu servidor de CI atual. É possível configurar essas credenciais usando variáveis de ambiente ou um arquivo .env.local. As variáveis de ambiente podem ser configuradas em um prompt interativo executando o seguinte comando:

gh actions-importer configure

Use os subcomandos de gh actions-importer para iniciar a migração para o Actions, incluindo audit, forecast, dry-run e migrate.

O subcomando audit pode ser usado para analisar seu volume de CI/CD atual, a fim de ajudar no planejamento da migração de CI/CD. Essa análise pode ser usada no planejamento de uma linha do tempo de migração para o Actions.

Para executar uma auditoria, use o seguinte comando a fim de determinar as opções disponíveis:

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

O subcomando forecast examina o uso histórico de pipelines para criar uma previsão de uso do Actions.

Para executar uma auditoria, use o seguinte comando a fim de determinar as opções disponíveis:

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

[...]

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

O subcomando dry-run pode ser usado para converter um pipeline em seu equivalente do Actions e, em seguida, gravar o fluxo de trabalho no sistema de arquivos local.

Para executar uma simulação, use o seguinte comando a fim de determinar as opções disponíveis:

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

[...]

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

O subcomando migrate pode ser usado para converter um pipeline em seu equivalente do Actions e, em seguida, criar uma solicitação de pull com o conteúdo.

Para executar uma migração, use o seguinte comando a fim de determinar as opções disponíveis:

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

[...]

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

Você pode usar Actions e Issues para executar comandos da CLI de Actions Importer. Isso permite que você migre seus fluxos de trabalho de CI/CD sem instalar software em seu computador local. Essa abordagem é especialmente útil para organizações que desejam habilitar migrações de autoatendimento para Actions. Depois que o IssueOps estiver configurado, os usuários poderão abrir um problema com o modelo relevante para migrar pipelines para Actions.

Para obter mais informações sobre como configurar migrações de autoatendimento com IssueOps, confira o repositório de modelos actions/importer-issue-ops.

O repositório de laboratórios do Actions Importer contém roteiros de aprendizagem específicos da plataforma que ensinam como usar o Actions Importer e abordar migrações para Actions. Você pode usar esse repositório para saber como usar Actions Importer para planejar, prever e automatizar sua migração para Actions.

Para saber mais, confira o Repositório de Laboratório de Importadores do Actions.

Partes foram adaptadas do https://.com//gh-actions-importer/ de acordo com a licença MIT:

MIT License

Copyright (c) 2022 

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.