generated from pmo-actions/healthchecks-ping
Actualiser action.yaml
This commit is contained in:
104
action.yaml
104
action.yaml
@@ -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
|
||||
@@ -37,56 +50,41 @@ runs:
|
||||
export DEBUG="ON"
|
||||
echo "DEBUG=ON" >> $GITEA_ENV
|
||||
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
|
||||
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 }}"
|
||||
check_command ${{ inputs.push_command }}
|
||||
|
||||
CURL_DATA=()
|
||||
if [[ -n "$MESSAGE" ]]; then
|
||||
CURL_DATA+=(--data-raw "$MESSAGE")
|
||||
fi
|
||||
|
||||
case "$COMMAND" in
|
||||
start|log|fail)
|
||||
URL="${HEALTHPOINT}/$COMMAND"
|
||||
;;
|
||||
IFS=' ' read -r -a tags <<< "${{ inputs.image_tags }}"
|
||||
debug "Tags parsed: ${tags[*]}"
|
||||
|
||||
stop)
|
||||
URL="${HEALTHPOINT}"
|
||||
;;
|
||||
*)
|
||||
error Error "Invalid command: $COMMAND (must be start|log|fail|stop)"
|
||||
;;
|
||||
esac
|
||||
sep=""
|
||||
if [[ -n "${tags[0]}" ]] ; then
|
||||
sep=":"
|
||||
fi
|
||||
|
||||
curl_cmd=(
|
||||
curl
|
||||
$OPTIONS
|
||||
"${CURL_DATA[@]}"
|
||||
"$URL"
|
||||
)
|
||||
|
||||
debug "Run command" "${curl_cmd[*]}"
|
||||
step "Start pushing" "${{ inputs.image_name }}}"
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user