generated from pmo-actions/healthchecks-ping
Actualiser action.yaml
This commit is contained in:
196
action.yaml
196
action.yaml
@@ -3,18 +3,46 @@ description: 'Description de l action'
|
|||||||
author: 'Eric Coissac'
|
author: 'Eric Coissac'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
|
image_name:
|
||||||
|
description: 'name of the image'
|
||||||
|
required: true
|
||||||
|
image_tags:
|
||||||
|
description: 'tags added to the image'
|
||||||
|
required: true
|
||||||
|
add_version_tag:
|
||||||
|
description: 'should I add a tag corresponding to the version of the packaged software'
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
build_command:
|
||||||
|
description: 'Command used to build the image (docker|podman)'
|
||||||
|
required: false
|
||||||
|
default: docker
|
||||||
|
tag_command:
|
||||||
|
description: 'Command used to tag the image (docker|podman)'
|
||||||
|
required: false
|
||||||
|
default: podman
|
||||||
|
registry_server:
|
||||||
|
description: 'Address of the image registry server'
|
||||||
|
required: false
|
||||||
|
default: "niepce.petite-maison-orange.fr"
|
||||||
|
registry_user:
|
||||||
|
description: 'User used for the connection to the image registry'
|
||||||
|
required: false
|
||||||
|
default: ${{ secrets.PMO_REGISTRY_USER }}
|
||||||
|
registry_password:
|
||||||
|
description: 'Password used for the connection to the image registry'
|
||||||
|
required: false
|
||||||
|
default: ${{ secrets.PMO_REGISTRY_PASSWORD }}
|
||||||
|
version_file:
|
||||||
|
description: 'Name of the file containing the version number'
|
||||||
|
required: false
|
||||||
|
default: 'software_version.txt'
|
||||||
check_server:
|
check_server:
|
||||||
description: 'Address of the Healthchecks server'
|
description: 'Address of the Healthchecks server'
|
||||||
required: true
|
required: false
|
||||||
|
default: 'https://haoma.petite-maison-orange.fr'
|
||||||
check_uuid:
|
check_uuid:
|
||||||
description: 'Deuxième paramètre'
|
description: 'Deuxième paramètre'
|
||||||
required: true
|
|
||||||
check_command:
|
|
||||||
description: 'Command to sen to the server can be nothing, start, log or fail'
|
|
||||||
required: false
|
|
||||||
default: 'stop'
|
|
||||||
check_message:
|
|
||||||
description: 'Message to log with the ping'
|
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
debug:
|
debug:
|
||||||
@@ -29,8 +57,9 @@ runs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Load bash library
|
- name: Load bash library
|
||||||
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/bash-library@main
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/bash-library@main
|
||||||
|
|
||||||
- name: Set debug mode
|
- name: Set debug mode
|
||||||
if: ${{ inputs.debug == 'true' }}
|
if: inputs.debug == 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
source "${{ github.action_path }}/../bashlib.sh"
|
source "${{ github.action_path }}/../bashlib.sh"
|
||||||
@@ -38,55 +67,126 @@ runs:
|
|||||||
echo "DEBUG=ON" >> $GITEA_ENV
|
echo "DEBUG=ON" >> $GITEA_ENV
|
||||||
debug Debug switch on
|
debug Debug switch on
|
||||||
|
|
||||||
- name: Ping the server
|
- name: Start the job
|
||||||
|
if: inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: start
|
||||||
|
check_message: 'Starting job for image ${{ inputs.image_name }}'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: Checkout and get version
|
||||||
|
id: get_version
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/software-version@main
|
||||||
|
with:
|
||||||
|
git_checkout: true
|
||||||
|
version_file: ${{ inputs.version_file }}
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: install podman
|
||||||
|
if: inputs.build_command == 'podman' || inputs.tag_command == 'podman'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
source "${{ github.action_path }}/../bashlib.sh"
|
source "${{ github.action_path }}/../bashlib.sh"
|
||||||
|
step "Install software" "podman"
|
||||||
|
|
||||||
check_command curl
|
if apt-get update && apt-get install -y podman ; then
|
||||||
|
success "Success" "Podman installation"
|
||||||
SERVER="${{ inputs.check_server }}"
|
else
|
||||||
HEALTHPOINT="${{ inputs.check_server }}/ping/${{ inputs.check_uuid }}"
|
error "Podman installation" "Failed"
|
||||||
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
|
fi
|
||||||
|
|
||||||
case "$COMMAND" in
|
- name: Build image starting
|
||||||
start|log|fail)
|
if: inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
URL="${HEALTHPOINT}/$COMMAND"
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
;;
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: log
|
||||||
|
check_message: 'Buildind docker image for ${{ steps.get_version.outputs.version }}'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
stop)
|
- name: Store tag version
|
||||||
URL="${HEALTHPOINT}"
|
shell: bash
|
||||||
;;
|
run: |
|
||||||
*)
|
echo "IMAGE_TAGS=${{ inputs.image_tags }}" >> $GITHUB_ENV
|
||||||
error Error "Invalid command: $COMMAND (must be start|log|fail|stop)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
curl_cmd=(
|
- name: Add PMO version tag
|
||||||
curl
|
if: inputs.add_version_tag == 'true'
|
||||||
$OPTIONS
|
run: |
|
||||||
"${CURL_DATA[@]}"
|
echo "IMAGE_TAGS=${{ env.IMAGE_TAGS }} pmo-${{ steps.get_version.outputs.version }}" >> $GITHUB_ENV
|
||||||
"$URL"
|
|
||||||
)
|
|
||||||
|
|
||||||
debug "Run command" "${curl_cmd[*]}"
|
- name: Build and tag image
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/build-image@main
|
||||||
result=$("${curl_cmd[@]}") \
|
with:
|
||||||
&& success "Success" "$COMMAND ping sent to ${SERVER}" \
|
image_name: '${{ inputs.image_name }}'
|
||||||
|| error "Error" "$COMMAND ping to ${SERVER} failed ${result}"
|
image_tags: '${{ env.IMAGE_TAGS }}'
|
||||||
|
registry_server: '${{ inputs.registry_server }}'
|
||||||
if [[ "$COMMAND" == "fail" ]] ; then
|
build_command: '${{ inputs.build_command }}'
|
||||||
exit 1
|
tag_command: '${{ inputs.tag_command }}'
|
||||||
fi
|
debug: ${{ inputs.debug }}
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
- name: Canceled building
|
||||||
|
if: cancelled() && inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: fail
|
||||||
|
check_message: 'Building image cancelled for ${{ inputs.image_name }}'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: Build image failed
|
||||||
|
if: failure() && inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: fail
|
||||||
|
check_message: 'Failed to build docker image for ${{ inputs.image_name }}'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: Image built and tagged
|
||||||
|
if: inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: log
|
||||||
|
check_message: 'Docker image for ${{ inputs.image_name }} built and tagged'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: Push image to registry
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/push-image@main
|
||||||
|
with:
|
||||||
|
registry_login: true
|
||||||
|
image_name: '${{ inputs.image_name }}'
|
||||||
|
image_tags: '${{ env.IMAGE_TAGS }}'
|
||||||
|
registry_server: '${{ inputs.registry_server }}'
|
||||||
|
registry_user: '${{ inputs.registry_user }}'
|
||||||
|
registry_password: '${{ inputs.registry_password }}'
|
||||||
|
push_command: '${{ inputs.tag_command }}'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: Push image failed
|
||||||
|
if: failure() && inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: fail
|
||||||
|
check_message: 'Failed to push docker image for ${{ inputs.image_name }}'
|
||||||
|
debug: ${{ inputs.debug }}
|
||||||
|
|
||||||
|
- name: End of the image building
|
||||||
|
if: inputs.check_server != '' && inputs.check_uuid != ''
|
||||||
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/healthchecks-ping@main
|
||||||
|
with:
|
||||||
|
check_server: ${{ inputs.check_server }}
|
||||||
|
check_uuid: ${{ inputs.check_uuid }}
|
||||||
|
check_command: stop
|
||||||
|
check_message: 'Docker image for ${{ inputs.image_name }}: task done'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user