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'
description: 'Description de l action'
name: 'Build a docker image to a registry server'
description: 'Build a docker image to a registry server using podman or docker'
author: 'Eric Coissac'
inputs:
check_server:
description: 'Address of the Healthchecks server'
image_name:
description: 'name of the image'
required: true
check_uuid:
description: 'Deuxième paramètre'
image_tags:
description: 'tags added to the image'
required: true
check_command:
description: 'Command to sen to the server can be nothing, start, log or fail'
registry_login:
decription: "Is the action must take care to log to the registry"
required: false
default: 'stop'
check_message:
description: 'Message to log with the ping'
default: false
type: boolean
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 }}
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:
description: 'Run the action in debug mode'
required: false
@@ -38,55 +51,40 @@ runs:
echo "DEBUG=ON" >> $GITEA_ENV
debug Debug switch on
- name: Ping the server
- 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: Push the images to the serveur
shell: bash
run: |
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 }}"
IFS=' ' read -r -a tags <<< "${{ inputs.image_tags }}"
debug "Tags parsed: ${tags[*]}"
CURL_DATA=()
if [[ -n "$MESSAGE" ]]; then
CURL_DATA+=(--data-raw "$MESSAGE")
sep=""
if [[ -n "${tags[0]}" ]] ; then
sep=":"
fi
case "$COMMAND" in
start|log|fail)
URL="${HEALTHPOINT}/$COMMAND"
;;
step "Start pushing" "${{ inputs.image_name }}}"
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
for tag in "${tags[@]}" ; do
if ${{ inputs.push_command }} push ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$tag ; then
success "Image pushing" "${{ inputs.image_name }}:${tag}"
else
error "Failed" "pushing of image ${{ inputs.image_name }}:${tag}"
fi
exit 0
done