Files

97 lines
4.5 KiB
Markdown
Raw Permalink Normal View History

2025-04-14 18:23:10 +02:00
# L'action `build-push-image`
2025-04-14 14:29:16 +02:00
2025-04-14 18:23:10 +02:00
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*.
2025-04-14 14:29:16 +02:00
---
## 🔧 Utilisation
```yaml
2025-04-14 18:23:10 +02:00
- 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
2025-04-14 14:29:16 +02:00
```
---
## 📥 Paramètres
2025-04-14 18:23:10 +02:00
| 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 |
2025-04-14 14:29:16 +02:00
---
2025-04-14 18:23:10 +02:00
## ▶️ Exemple de workflow complet
2025-04-14 14:29:16 +02:00
```yaml
2025-04-14 18:23:10 +02:00
name: Build and Deploy
on: [push]
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
2025-04-14 14:29:16 +02:00
```
---
## ⚙️ Comportement
2025-04-14 18:23:10 +02:00
### É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
2025-04-14 14:29:16 +02:00
---
## 🧡 À propos
Cette action fait partie des actions de la **Petite Maison Orange**.
2025-04-14 18:23:10 +02:00
👉 [https://gargoton.petite-maison-orange.fr/pmo-actions/](https://gargoton.petite-maison-orange.fr/pmo-actions/)