From 9bd2092c8167012c47fea2174a94220ed5cefee7 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Mon, 14 Apr 2025 08:41:32 +0200 Subject: [PATCH] Actualiser action.yaml --- action.yaml | 75 ++++++++++++++--------------------------------------- 1 file changed, 19 insertions(+), 56 deletions(-) diff --git a/action.yaml b/action.yaml index b80a4d3..fa668f8 100644 --- a/action.yaml +++ b/action.yaml @@ -1,69 +1,32 @@ -name: 'Ping a Healthchecks.io server' -description: 'Description de l action' +name: 'Connect to a docker registry' +description: 'Connection to a docker registry using podman' 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' + registry_server: + description: 'Address of the image registry server' required: false - default: 'stop' - message: - description: 'Message to log with the ping' + default: "niepce.petite-maison-orange.fr" + registry_user: + description: 'User used for the connection to the image registry' required: false - default: '' - - + default: ${{ secrets.PMO_REGISTRY_USER }} + registry_password: + description: 'Password used for the connection to the image registry' + required: false + default: ${{ secrets.PMO_REGISTRY_PASSWORD }} + runs: using: 'composite' steps: - - name: Ping the server + - name: Podman connection to the registry shell: bash run: | - 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 "::error::Commande invalide: $COMMAND" - exit 1 - ;; - esac - - curl_cmd=( - curl - $OPTIONS - "${CURL_DATA[@]}" - "$URL" - ) - - echo "Commande exécutée: ${curl_cmd[*]}" - - "${curl_cmd[@]}" # Exécution sans eval - - if [[ "$COMMAND" == "fail" ]] ; then - exit 1 - fi - exit 0 + echo -e "Connection to registry: ${{ inputs.registry_server }}...\c" + podman login ${{ inputs.registry_server }} \ + -u ${{ inputs.registry_user }} \ + -p ${{ inputs.registry_password }} \ + && echo " Done."