generated from pmo-actions/healthchecks-ping
Initial commit
This commit is contained in:
66
README.md
Normal file
66
README.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# L'action `healthchecks-ping`
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Utilisation
|
||||
|
||||
```yaml
|
||||
- name: Notify healthchecks
|
||||
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📥 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é. |
|
||||
|
||||
---
|
||||
|
||||
## ▶️ Exemple de workflow
|
||||
|
||||
```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 my project
|
||||
run: make build
|
||||
|
||||
- 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 ✅"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ 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://<check_server>/ping/<uuid>` *(commande `stop` ou vide)*
|
||||
- `https://<check_server>/ping/<uuid>/<check_command>` *(commande `start`, `log`, `fail`)*
|
||||
|
||||
---
|
||||
|
||||
## 🧡 À 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/)
|
||||
92
action.yaml
Normal file
92
action.yaml
Normal file
@@ -0,0 +1,92 @@
|
||||
name: 'Ping a Healthchecks.io server'
|
||||
description: 'Description de l action'
|
||||
author: 'Eric Coissac'
|
||||
|
||||
inputs:
|
||||
check_server:
|
||||
description: 'Address of the Healthchecks server'
|
||||
required: true
|
||||
check_uuid:
|
||||
description: 'Deuxième paramètre'
|
||||
required: true
|
||||
check_command:
|
||||
description: 'Command to sen to the server can be nothing, start, log or fail'
|
||||
required: false
|
||||
default: 'stop'
|
||||
check_message:
|
||||
description: 'Message to log with the ping'
|
||||
required: false
|
||||
default: ''
|
||||
debug:
|
||||
description: 'Run the action in debug mode'
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Load bash library
|
||||
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/bash-library@main
|
||||
- name: Set debug mode
|
||||
if: ${{ inputs.debug == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
source "${{ github.action_path }}/../bashlib.sh"
|
||||
export DEBUG="ON"
|
||||
echo "DEBUG=ON" >> $GITEA_ENV
|
||||
debug Debug switch on
|
||||
|
||||
- name: Ping the server
|
||||
shell: bash
|
||||
run: |
|
||||
source "${{ github.action_path }}/../bashlib.sh"
|
||||
|
||||
check_command curl
|
||||
|
||||
SERVER="${{ inputs.check_server }}"
|
||||
HEALTHPOINT="${{ inputs.check_server }}/ping/${{ inputs.check_uuid }}"
|
||||
OPTIONS="-fsS -m 10 --retry 5"
|
||||
MESSAGE="${{ inputs.check_message }}"
|
||||
COMMAND="${{ inputs.check_command }}"
|
||||
|
||||
CURL_DATA=()
|
||||
if [[ -n "$MESSAGE" ]]; then
|
||||
CURL_DATA+=(--data-raw "$MESSAGE")
|
||||
fi
|
||||
|
||||
case "$COMMAND" in
|
||||
start|log|fail)
|
||||
URL="${HEALTHPOINT}/$COMMAND"
|
||||
;;
|
||||
|
||||
stop)
|
||||
URL="${HEALTHPOINT}"
|
||||
;;
|
||||
*)
|
||||
error Error "Invalid command: $COMMAND (must be start|log|fail|stop)"
|
||||
;;
|
||||
esac
|
||||
|
||||
curl_cmd=(
|
||||
curl
|
||||
$OPTIONS
|
||||
"${CURL_DATA[@]}"
|
||||
"$URL"
|
||||
)
|
||||
|
||||
debug "Run command" "${curl_cmd[*]}"
|
||||
|
||||
result=$("${curl_cmd[@]}") \
|
||||
&& success "Success" "$COMMAND ping sent to ${SERVER}" \
|
||||
|| error "Error" "$COMMAND ping to ${SERVER} failed ${result}"
|
||||
|
||||
if [[ "$COMMAND" == "fail" ]] ; then
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user