Skip to main content

Automatisation de la migration avec GitHub Actions Importer

Utilisez GitHub Actions Importer pour planifier et automatiser votre migration vers GitHub Actions.

Mentions légales

À propos de GitHub Actions Importer

Vous pouvez utiliser GitHub Actions Importer pour planifier vos pipelines pris en charge par CI/CD et les migrer automatiquement vers GitHub Actions.

GitHub Actions Importer est distribué en tant que conteneur Docker et utilise une extension CLI GitHub pour interagir avec le conteneur.

Tout workflow converti par GitHub Actions Importer doit être inspecté pour vérifier son exactitude avant de l’utiliser en tant que charge de travail de production. L’objectif est d’atteindre un taux de conversion de 80 % pour chaque workflow. Toutefois, le taux de conversion réel dépend de la composition de chaque pipeline qui est converti.

Plateformes CI prises en charge

Vous pouvez utiliser GitHub Actions Importer pour effectuer une migration à partir des plateformes suivantes :

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

Prérequis

GitHub Actions Importer a les exigences suivantes :

  • Un environnement dans lequel vous pouvez exécuter des conteneurs basés sur Linux et installer les outils nécessaires.

    Remarque : Le conteneur GitHub Actions Importer et l’interface CLI n’ont pas besoin d’être installés sur le même serveur que votre plateforme CI.

Installation de l’extension CLI GitHub Actions Importer

  1. Installez l’extension CLI GitHub Actions Importer :

    Bash
    gh extension install github/gh-actions-importer
    
  2. Vérifiez que l’extension est installée :

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

Mise à jour de l’interface CLI GitHub Actions Importer

Pour vous assurer que vous exécutez la dernière version de GitHub Actions Importer, vous devez exécuter régulièrement la commande update :

gh actions-importer update

Authentification depuis la ligne de commande

Vous devez configurer des informations d’identification qui permettent à GitHub Actions Importer de communiquer avec GitHub et votre serveur CI actuel. Vous pouvez configurer ces informations d’identification en utilisant des variables d’environnement ou un fichier .env.local. Vous pouvez configurer les variables d’environnement dans une invite interactive, en exécutant la commande suivante :

gh actions-importer configure

Utilisation de l’interface CLI GitHub Actions Importer

Utilisez les sous-commandes de gh actions-importer pour commencer votre migration vers GitHub Actions, notamment audit, forecast, dry-run et migrate.

Audit de vos pipelines CI existants

La sous-commande audit peut être utilisée pour planifier votre migration CI/CD en analysant votre empreinte CI/CD actuelle. Cette analyse peut être utilisée pour planifier une chronologie de migration vers GitHub Actions.

Pour exécuter un audit, utilisez la commande suivante afin de déterminer les options dont vous disposez :

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

Prévision de l’utilisation

La sous-commande forecast passe en revue l’utilisation historique du pipeline pour créer une prévision de l’utilisation de GitHub Actions.

Pour exécuter une prévision, utilisez la commande suivante afin de déterminer les options dont vous disposez :

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

Test du processus de migration

La sous-commande dry-run peut être utilisée pour convertir un pipeline en son équivalent GitHub Actions, puis écrire le workflow dans votre système de fichiers local.

Pour effectuer un test, utilisez la commande suivante afin de déterminer les options dont vous disposez :

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

Migration d’un pipeline vers GitHub Actions

La sous-commande migrate peut être utilisée pour convertir un pipeline en son équivalent GitHub Actions, puis créer une demande de tirage (pull request) avec le contenu.

Pour exécuter une migration, utilisez la commande suivante afin de déterminer les options dont vous disposez :

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

Effectuer des migrations en libre-service à l’aide d’IssueOps

Vous pouvez utiliser GitHub Actions et GitHub Issues pour exécuter des commandes CLI pour GitHub Actions Importer. Cela vous permet de migrer vos workflows CI/CD sans installer de logiciel sur votre ordinateur local. Cette approche est particulièrement utile pour les organisations qui souhaitent activer les migrations en libre-service vers GitHub Actions. Une fois IssueOps configuré, les utilisateurs peuvent ouvrir un problème avec le modèle approprié pour migrer des pipelines vers GitHub Actions.

Pour plus d’informations sur la configuration des migrations libre-service avec IssueOps, consultez le dépôt de modèles actions/importer-issue-ops.

Utilisation du dépôt de labs GitHub Actions Importer

Le dépôt de labs GitHub Actions Importer contient des parcours d’apprentissage spécifiques à la plateforme qui vous apprennent à utiliser GitHub Actions Importer et à aborder les migrations vers GitHub Actions. Vous pouvez utiliser ce dépôt pour apprendre à utiliser GitHub Actions Importer pour vous aider à planifier, prévoir et automatiser votre migration vers GitHub Actions.

Pour plus d’informations, consultez le dépôt de labs GitHub Actions Importer.

Certaines parties ont été adaptées à partir de https://github.com/github/gh-actions-importer/ sous la licence 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.