name: 'Ping a Healthchecks.io server' description: 'Description de l action' author: 'Eric Coissac' inputs: server: description: 'Address of the Healthchecks server' required: true uuid: description: 'Deuxième paramètre' required: true command: description: 'Command to sen to the server can be nothing, start, log or fail' required: false default: 'stop' message: description: 'Message to log with the ping' required: false default: '' debug: decrtio runs: using: 'composite' steps: - name: Ping the server shell: bash run: | GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color if [[ -z $(which curl) ]] ; then echo -e "${RED}❌ Error:${NC}: Cannot locate the curl command" exit 1 fi HEALTHPOINT="${{ inputs.server }}/ping/${{ inputs.uuid }}" OPTIONS="-fsS -m 10 --retry 5" MESSAGE="${{ inputs.message }}" COMMAND="${{ inputs.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}" ;; *) echo "${RED}❌ Error:${NC}: Commande invalide: $COMMAND" exit 1 ;; esac curl_cmd=( curl $OPTIONS "${CURL_DATA[@]}" "$URL" ) echo -e "${YELLOW}🔄 Commande exécutée:${NC} ${curl_cmd[*]}" "${curl_cmd[@]}" \ && echo -e "${GREEN}✅ Success:${NC} $COMMAND ping sent to ${HEALTHPOINT}" \ || echo -e "${RED}❌ Error: ${NC} $COMMAND ping to ${HEALTHPOINT} failed" if [[ "$COMMAND" == "fail" ]] ; then exit 1 fi exit 0