{"id":5330,"date":"2025-07-23T13:35:09","date_gmt":"2025-07-23T13:35:09","guid":{"rendered":"https:\/\/techhub.saworks.io\/docs\/tutoriel-github\/automatisez-votre-workflow-avec-github-actions-partie-2-sur-2\/github-packages-pour-les-paquets-de-code\/"},"modified":"2025-07-25T16:04:58","modified_gmt":"2025-07-25T16:04:58","slug":"github-packages-pour-les-paquets-de-code","status":"publish","type":"docs","link":"https:\/\/techhub.saworks.io\/fr\/docs\/tutoriel-github\/automatisez-votre-workflow-avec-github-actions-partie-2-sur-2\/github-packages-pour-les-paquets-de-code\/","title":{"rendered":"GitHub Packages pour les paquets de code"},"content":{"rendered":"\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>Dans l\u2019unit\u00e9 pr\u00e9c\u00e9dente, vous avez vu comment utiliser&nbsp;<strong>GitHub Actions<\/strong>&nbsp;pour construire et publier des images de conteneurs.<\/p>\n\n\n\n<p>Dans cette unit\u00e9, nous allons explorer les autres types de paquets pris en charge par&nbsp;<strong>GitHub Packages<\/strong>. GitHub Packages fonctionne avec les outils de l\u2019\u00e9cosyst\u00e8me de votre projet :&nbsp;<strong>npm<\/strong>&nbsp;pour les paquets npm,&nbsp;<strong>nuget.exe<\/strong>&nbsp;ou l\u2019interface en ligne de commande&nbsp;<strong>dotnet<\/strong>&nbsp;pour les paquets NuGet, etc.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>S\u2019authentifier aupr\u00e8s de GitHub Packages<\/strong><\/h3>\n\n\n\n<p>La m\u00e9thode d\u2019authentification dans votre gestionnaire de paquets d\u00e9pendra de l\u2019\u00e9cosyst\u00e8me de votre projet. Quel que soit l\u2019\u00e9cosyst\u00e8me utilis\u00e9, vous aurez besoin de trois \u00e9l\u00e9ments :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Votre&nbsp;<strong>nom d\u2019utilisateur GitHub<\/strong><\/li>\n\n\n\n<li>Un&nbsp;<strong>jeton d\u2019acc\u00e8s personnel (PAT)<\/strong><\/li>\n\n\n\n<li>L\u2019<strong>URL de GitHub Packages<\/strong>&nbsp;correspondant \u00e0 votre \u00e9cosyst\u00e8me de paquets<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>G\u00e9n\u00e9rer un jeton d\u2019acc\u00e8s personnel<\/strong><\/h3>\n\n\n\n<p>Pour&nbsp;<strong>installer<\/strong>,&nbsp;<strong>publier<\/strong>&nbsp;ou&nbsp;<strong>supprimer<\/strong>&nbsp;un paquet, vous avez besoin d\u2019un&nbsp;<strong>jeton d\u2019acc\u00e8s<\/strong>. Lors de l\u2019utilisation de votre gestionnaire de paquets, vous devez g\u00e9n\u00e9rer un&nbsp;<strong>jeton d\u2019acc\u00e8s personnel (PAT)<\/strong>. Vous pouvez le faire via les&nbsp;<strong>param\u00e8tres de votre profil GitHub<\/strong>.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-group has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"border-width:1px;border-radius:10px;background-color:#f7944d7d\">\n<p>\u26a0\ufe0f&nbsp;<strong>Avertissement<\/strong><\/p>\n\n\n\n<p><br>Traitez vos jetons comme des mots de passe et gardez-les secrets.<\/p>\n<\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Se connecter \u00e0 GitHub Packages<\/strong><\/h3>\n\n\n\n<p>Avant de publier ou d\u2019installer des paquets depuis GitHub Packages, vous devez vous&nbsp;<strong>authentifier<\/strong>&nbsp;dans votre gestionnaire de paquets. L\u2019URL ressemblera \u00e0 ceci :<br><code>https:\/\/PACKAGE_TYPE.pkg.github.com\/OWNER\/REPOSITORY<\/code>,<br>o\u00f9&nbsp;<strong>PACKAGE_TYPE<\/strong>&nbsp;est le type d\u2019\u00e9cosyst\u00e8me de paquets que vous utilisez.<\/p>\n\n\n\n<p>La table suivante (non incluse ici) vous montre la commande \u00e0 ex\u00e9cuter pour vous authentifier aupr\u00e8s de GitHub Packages selon votre \u00e9cosyst\u00e8me.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u00c9cosyst\u00e8me de paquets<\/th><th>Commande pour s\u2019authentifier<\/th><\/tr><\/thead><tbody><tr><td><strong>NuGet<\/strong><\/td><td><code>dotnet nuget add source https:\/\/nuget.pkg.github.com\/OWNER\/index.json -n github -u OWNER -p [Votre jeton PAT]<\/code><\/td><\/tr><tr><td><strong>npm<\/strong><\/td><td><code>npm login --registry=https:\/\/npm.pkg.github.com<\/code><\/td><\/tr><tr><td><strong>RubyGems<\/strong><\/td><td><code>echo \":github: Bearer GH_TOKEN\" &gt;&gt; ~\/.gem\/credentials<\/code><\/td><\/tr><tr><td><strong>Maven &amp; Gradle<\/strong><\/td><td>Authentification directe lors du push<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Si vous souhaitez en savoir plus sur la fa\u00e7on d\u2019utiliser&nbsp;<strong>GitHub Packages<\/strong>&nbsp;avec l\u2019environnement de votre projet, vous pouvez consulter la documentation ici&nbsp;<em>(lien vers la documentation officielle)<\/em>.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Installer un paquet<\/strong><\/h3>\n\n\n\n<p>Une fois authentifi\u00e9, vous pouvez facilement utiliser les paquets publi\u00e9s dans vos projets. Chaque page de paquet affiche la commande \u00e0 ex\u00e9cuter, en fonction de l\u2019environnement de votre projet.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"772\" height=\"490\" data-src=\"https:\/\/techhub.saworks.io\/wp-content\/uploads\/2025\/07\/5-github-packages-install.png\" alt=\"\" class=\"wp-image-5333 lazyload\" data-srcset=\"https:\/\/techhub.saworks.io\/wp-content\/uploads\/2025\/07\/5-github-packages-install.png 772w, https:\/\/techhub.saworks.io\/wp-content\/uploads\/2025\/07\/5-github-packages-install-300x190.png 300w, https:\/\/techhub.saworks.io\/wp-content\/uploads\/2025\/07\/5-github-packages-install-768x487.png 768w\" data-sizes=\"(max-width: 772px) 100vw, 772px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 772px; --smush-placeholder-aspect-ratio: 772\/490;\" \/><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>G\u00e9rer les paquets<\/strong><\/h3>\n\n\n\n<p><strong>GitHub Packages<\/strong>&nbsp;vous offre plusieurs moyens simples pour g\u00e9rer le&nbsp;<strong>cycle de vie<\/strong>&nbsp;et les&nbsp;<strong>workflows<\/strong>&nbsp;de vos paquets.<\/p>\n\n\n\n<p>Vous pouvez g\u00e9rer les paquets GitHub via l\u2019<strong>API GitHub REST<\/strong>&nbsp;et l\u2019<strong>API GraphQL<\/strong>. Ces API permettent de prendre en charge des sc\u00e9narios d\u2019int\u00e9gration avanc\u00e9s. Par exemple, gr\u00e2ce \u00e0 la fonctionnalit\u00e9&nbsp;<strong>Webhook<\/strong>&nbsp;de GitHub, vous pouvez ex\u00e9cuter du code lorsqu\u2019un nouveau paquet est publi\u00e9. Imaginez que vous \u00eates mainteneur d\u2019un projet open source : avec les webhooks, vous pourriez automatiquement publier un&nbsp;<strong>tweet<\/strong>&nbsp;ou un&nbsp;<strong>article de blog<\/strong>&nbsp;d\u00e8s qu\u2019un nouveau paquet est mis en ligne.<\/p>\n\n\n\n<p>Vous pouvez \u00e9galement utiliser&nbsp;<strong>GitHub Actions<\/strong>&nbsp;pour automatiser la gestion des paquets. Par exemple, avec l\u2019action&nbsp;<strong><code>delete-package-versions<\/code><\/strong>, vous pouvez automatiquement&nbsp;<strong>supprimer les versions les plus anciennes<\/strong>&nbsp;de vos paquets lors de la publication d\u2019une nouvelle version.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Dans l\u2019unit\u00e9 pr\u00e9c\u00e9dente, vous avez vu comment utiliser&nbsp;GitHub Actions&nbsp;pour construire et publier des images de conteneurs. Dans cette unit\u00e9, nous allons explorer les [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":5295,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"doc_badge":[],"class_list":["post-5330","docs","type-docs","status-publish","hentry"],"author_avatar":"https:\/\/secure.gravatar.com\/avatar\/6a70e7c73db9f245e650948d09d74f61?s=96&d=mm&r=g","author_name":"Annick N'dri","_links":{"self":[{"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/docs\/5330"}],"collection":[{"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/comments?post=5330"}],"version-history":[{"count":0,"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/docs\/5330\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/docs\/5295"}],"wp:attachment":[{"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/media?parent=5330"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/doc_tag?post=5330"},{"taxonomy":"doc_badge","embeddable":true,"href":"https:\/\/techhub.saworks.io\/fr\/wp-json\/wp\/v2\/doc_badge?post=5330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}