From 200956a72ca76e0be1699be1f1606f52c15b3fb1 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Mon, 14 Apr 2025 13:59:09 +0200 Subject: [PATCH] Actualiser action.yaml --- action.yaml | 84 +++++++++++++++-------------------------------------- 1 file changed, 24 insertions(+), 60 deletions(-) diff --git a/action.yaml b/action.yaml index 8c71453..d4dd5b2 100644 --- a/action.yaml +++ b/action.yaml @@ -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" + # 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:]]*$//') - 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 - + echo "::set-output name=version::${SOFTVERSION}"