Actualiser action.yaml

This commit is contained in:
2025-04-14 13:17:47 +02:00
parent 5fb998e733
commit 0ef9646f90

View File

@@ -1,22 +1,35 @@
name: 'Ping a Healthchecks.io server' name: 'Build a docker image to a registry server'
description: 'Description de l action' description: 'Build a docker image to a registry server using podman or docker'
author: 'Eric Coissac' author: 'Eric Coissac'
inputs: inputs:
check_server: image_name:
description: 'Address of the Healthchecks server' description: 'name of the image'
required: true required: true
check_uuid: image_tags:
description: 'Deuxième paramètre' description: 'tags added to the image'
required: true required: true
check_command: registry_login:
description: 'Command to sen to the server can be nothing, start, log or fail' decription: "Is the action must take care to log to the registry"
required: false required: false
default: 'stop' default: false
check_message: type: boolean
description: 'Message to log with the ping' registry_user:
description: 'User used for the connection to the image registry'
required: false 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 }}
registry_server:
description: 'Address of the image registry server'
required: false
default: "niepce.petite-maison-orange.fr"
push_command:
description: 'Command used to push the image (docker|podman)'
required: false
default: podman
debug: debug:
description: 'Run the action in debug mode' description: 'Run the action in debug mode'
required: false required: false
@@ -37,56 +50,41 @@ runs:
export DEBUG="ON" export DEBUG="ON"
echo "DEBUG=ON" >> $GITEA_ENV echo "DEBUG=ON" >> $GITEA_ENV
debug Debug switch on debug Debug switch on
- name: Log into the registry
if: ${{ inputs.registry_login == true }}
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/registry-login@main
with:
registry_command: ${{ inputs.push_command }}
registry_server: ${{ inputs.registry_server }}
registry_user: ${{ inputs.registry_user }}
registry_password: ${{ inputs.registry_password }}
debug: ${{ inputs.debug }}
- name: Ping the server - name: Push the images to the serveur
shell: bash shell: bash
run: | run: |
source "${{ github.action_path }}/../bashlib.sh" source "${{ github.action_path }}/../bashlib.sh"
check_command curl check_command ${{ inputs.push_command }}
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=() IFS=' ' read -r -a tags <<< "${{ inputs.image_tags }}"
if [[ -n "$MESSAGE" ]]; then debug "Tags parsed: ${tags[*]}"
CURL_DATA+=(--data-raw "$MESSAGE")
fi
case "$COMMAND" in
start|log|fail)
URL="${HEALTHPOINT}/$COMMAND"
;;
stop) sep=""
URL="${HEALTHPOINT}" if [[ -n "${tags[0]}" ]] ; then
;; sep=":"
*) fi
error Error "Invalid command: $COMMAND (must be start|log|fail|stop)"
;;
esac
curl_cmd=( step "Start pushing" "${{ inputs.image_name }}}"
curl
$OPTIONS
"${CURL_DATA[@]}"
"$URL"
)
debug "Run command" "${curl_cmd[*]}"
result=$("${curl_cmd[@]}") \ for tag in "${tags[@]}" ; do
&& success "Success" "$COMMAND ping sent to ${SERVER}" \ if ${{ inputs.push_command }} push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$tag ; then
|| error "Error" "$COMMAND ping to ${SERVER} failed ${result}" success "Image pushing" "${{ inputs.image_name }}:${tag}"
else
if [[ "$COMMAND" == "fail" ]] ; then error "Failed" "pushing of image ${{ inputs.image_name }}:${tag}"
exit 1 fi
fi done
exit 0