91 lines
2.2 KiB
YAML
91 lines
2.2 KiB
YAML
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: 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
|
|
|
|
|
|
|
|
|