generated from pmo-actions/healthchecks-ping
98 lines
2.9 KiB
YAML
98 lines
2.9 KiB
YAML
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:
|
|
image_name:
|
|
description: 'name of the image'
|
|
required: true
|
|
image_tags:
|
|
description: 'tags added to the image'
|
|
required: true
|
|
registry_login:
|
|
decription: "Is the action must take care to log to the registry"
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
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 }}
|
|
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
|
|
default: false
|
|
type: boolean
|
|
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Load bash library
|
|
uses: https://gargoton.petite-maison-orange.fr/pmo-actions/bash-library@main
|
|
- name: Set debug mode
|
|
if: ${{ inputs.debug == 'true' }}
|
|
shell: bash
|
|
run: |
|
|
source "${{ github.action_path }}/../bashlib.sh"
|
|
export DEBUG="ON"
|
|
echo "DEBUG=ON" >> $GITEA_ENV
|
|
debug Debug switch on
|
|
|
|
- name: Debug registry_login
|
|
shell: bash
|
|
run: |
|
|
source "${{ github.action_path }}/../bashlib.sh"
|
|
debug "Registry login is set to -${{ inputs.registry_login }}-"
|
|
|
|
|
|
- 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 ${{ inputs.push_command }}
|
|
|
|
IFS=' ' read -r -a tags <<< "${{ inputs.image_tags }}"
|
|
debug "Tags parsed: ${tags[*]}"
|
|
|
|
sep=""
|
|
if [[ -n "${tags[0]}" ]] ; then
|
|
sep=":"
|
|
fi
|
|
|
|
step "Start pushing" "${{ inputs.image_name }}}"
|
|
|
|
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
|
|
|
|
|
|
|