Actualiser action.yaml

This commit is contained in:
2025-04-14 13:59:09 +02:00
parent 39dbe7490c
commit 200956a72c

View File

@@ -3,26 +3,26 @@ 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'
git_checkout:
description: 'Shall I checkout the git'
required: false
default: 'stop'
check_message:
description: 'Message to log with the ping'
default: false
type: boolean
version_file:
description: 'Name of the file containing the version number'
required: false
default: ''
default: 'software_version.txt'
debug:
description: 'Run the action in debug mode'
required: false
default: false
type: boolean
outputs:
version:
description: 'The version of the software packaged in the image'
runs:
using: 'composite'
@@ -30,7 +30,7 @@ runs:
- name: Load bash library
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/bash-library@main
- name: Set debug mode
if: ${{ inputs.debug == true }}
if: ${{ inputs.debug == 'true' }}
shell: bash
run: |
source "${{ github.action_path }}/../bashlib.sh"
@@ -38,55 +38,19 @@ runs:
echo "DEBUG=ON" >> $GITEA_ENV
debug Debug switch on
- name: Ping the server
shell: bash
- name: Checkout code
if: ${{ inputs.git_checkout == 'true' }}
uses: actions/checkout@v4
- name: retrieve the version
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
# Lire le contenu du fichier et supprimer les espaces/retours chariots
SOFTVERSION=$(cat ${{ inputs.version_file }} \
| head -n 1 \
| tr -d ' \n' \
| sed -E 's/^[[:space:]]*//;s/[[:space:]]*$//')
echo "::set-output name=version::${SOFTVERSION}"