From 69adfee3d301ad51b4129f87683937079c636316 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Mon, 14 Apr 2025 18:23:10 +0200 Subject: [PATCH] Actualiser README.md --- README.md | 99 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index cf4e541..299841c 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,97 @@ -# L'action `healthchecks-ping` +# L'action `build-push-image` -Cette action permet d’envoyer un *ping* vers un serveur [Healthchecks.io](https://healthchecks.io) (ou un serveur compatible). -Elle est conçue pour être utilisée dans des workflows Gitea avec des runners auto-hébergés. +Cette action permet de **construire une image conteneur**, de la taguer, de la pousser vers un registre et de notifier [Healthchecks.io](https://healthchecks.io) à chaque étape. +Elle intègre des fonctionnalités de gestion de versions, de notifications et supporte *Docker* ou *Podman*. --- ## 🔧 Utilisation ```yaml -- name: Notify healthchecks - uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main +- name: Build and push image + uses: https://gargoton.petite-maison-orange.fr/pmo-actions/build-push-image@main + with: + image_name: mon-projet + image_tags: latest + check_server: https://haoma.petite-maison-orange.fr + check_uuid: x1y2z3-1234-5678-9abc-def123456789 ``` --- ## 📥 Paramètres -| Nom | Obligatoire | Par défaut | Description | -|------------------|-------------|------------|-----------------------------------------------------------------------------| -| `check_server` | ✅ | – | Adresse du serveur Healthchecks, incluant `https://`. | -| `check_uuid` | ✅ | – | Identifiant UUID de la vérification. | -| `check_command` | ❌ | `stop` | Commande : `start`, `log`, `fail`, ou `stop`. | -| `check_message` | ❌ | `""` | Message transmis avec le ping (visible dans l’interface Healthchecks). | -| `debug` | ❌ | `false` | Affiche des messages de debug détaillés si activé. | +| Nom | Obligatoire | Par défaut | Description | +|------------------------|-------------|-------------------------------------|-----------------------------------------------------------------------------| +| `image_name` | ✅ | – | Nom de l'image à construire | +| `image_tags` | ✅ | – | Tags de l'image (séparés par des espaces) | +| `add_version_tag` | ❌ | `true` | Ajoute un tag basé sur la version (ex: `pmo-1.2.3`) | +| `version_tag_prefix` | ❌ | `pmo` | Préfixe du tag de version | +| `build_command` | ❌ | `docker` | Outil de build (`docker`/`podman`) | +| `tag_command` | ❌ | `podman` | Outil de tagging (`docker`/`podman`) | +| `registry_server` | ❌ | `niepce.petite-maison-orange.fr` | URL du registre | +| `registry_user` | ❌ | `${{ secrets.PMO_REGISTRY_USER }}` | Utilisateur du registre | +| `registry_password` | ❌ | `${{ secrets.PMO_REGISTRY_PASSWORD }}` | Mot de passe du registre | +| `version_file` | ❌ | `software_version.txt` | Fichier contenant la version | +| `check_server` | ❌ | `https://haoma.petite-maison-orange.fr` | Serveur Healthchecks (vide = désactivé) | +| `check_uuid` | ❌ | – | UUID de la vérification Healthchecks | +| `debug` | ❌ | `false` | Active les logs de débogage | --- -## ▶️ Exemple de workflow +## ▶️ Exemple de workflow complet ```yaml -- name: Notify healthchecks (start) - uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main - with: - check_server: https://hc-ping.com - check_uuid: a1b2c3d4-1234-5678-9abc-def123456789 - check_command: start +name: Build and Deploy -- name: Build my project - run: make build +on: [push] -- name: Notify healthchecks (stop) - uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main - with: - check_server: https://hc-ping.com - check_uuid: a1b2c3d4-1234-5678-9abc-def123456789 - check_message: "Build terminé avec succès ✅" +jobs: + build: + runs-on: self-hosted + steps: + - name: Build and push image + uses: https://gargoton.petite-maison-orange.fr/pmo-actions/build-push-image@main + with: + image_name: api-server + image_tags: "latest staging" + add_version_tag: true + version_tag_prefix: "v" + build_command: podman + registry_server: registry.example.com + registry_user: ${{ secrets.REGISTRY_USER }} + registry_password: ${{ secrets.REGISTRY_PASSWORD }} + check_server: https://hc-ping.com + check_uuid: a1b2c3d4-1234-5678-9abc-def123456789 + debug: true ``` --- ## ⚙️ Comportement -- Si `check_command: fail` est utilisé, **l’action échoue volontairement** (`exit 1`). -- Si `curl` échoue, l’action affiche l’erreur et échoue également. -- L’URL appelée par `curl` dépend de la commande : - - `https:///ping/` *(commande `stop` ou vide)* - - `https:///ping//` *(commande `start`, `log`, `fail`)* +### Étapes clés +1. **Notifications Healthchecks** (si activé) : + - Début de la tâche (`start`) + - Log pendant le build (`log`) + - Échec en cas d'annulation/erreur (`fail`) + - Succès final (`stop`) + +2. **Gestion des versions** : + - Récupère la version depuis `software_version.txt` + - Ajoute un tag versionné (ex: `pmo-1.0.0`) + +3. **Construction de l'image** : + - Installation auto de Podman si besoin + - Build avec `docker`/`podman` + +4. **Push vers le registre** : + - Authentification automatique + - Push multi-tags --- ## 🧡 À propos Cette action fait partie des actions de la **Petite Maison Orange**. -Toutes les actions sont disponibles ici : -👉 [https://gargoton.petite-maison-orange.fr/pmo-actions/](https://gargoton.petite-maison-orange.fr/pmo-actions/) +👉 [https://gargoton.petite-maison-orange.fr/pmo-actions/](https://gargoton.petite-maison-orange.fr/pmo-actions/) \ No newline at end of file