Files
push-image/action.yaml

98 lines
2.9 KiB
YAML
Raw Normal View History

2025-04-14 13:17:47 +02:00
name: 'Build a docker image to a registry server'
description: 'Build a docker image to a registry server using podman or docker'
2025-04-14 13:02:19 +02:00
author: 'Eric Coissac'
inputs:
2025-04-14 13:17:47 +02:00
image_name:
description: 'name of the image'
2025-04-14 13:02:19 +02:00
required: true
2025-04-14 13:17:47 +02:00
image_tags:
description: 'tags added to the image'
2025-04-14 13:02:19 +02:00
required: true
2025-04-14 13:17:47 +02:00
registry_login:
decription: "Is the action must take care to log to the registry"
2025-04-14 13:02:19 +02:00
required: false
2025-04-14 13:17:47 +02:00
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'
2025-04-14 13:02:19 +02:00
required: false
2025-04-14 13:17:47 +02:00
default: "niepce.petite-maison-orange.fr"
push_command:
description: 'Command used to push the image (docker|podman)'
required: false
default: podman
2025-04-14 13:02:19 +02:00
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
2025-04-14 13:32:39 +02:00
if: ${{ inputs.debug == 'true' }}
2025-04-14 13:02:19 +02:00
shell: bash
run: |
source "${{ github.action_path }}/../bashlib.sh"
export DEBUG="ON"
echo "DEBUG=ON" >> $GITEA_ENV
debug Debug switch on
2025-04-14 13:17:47 +02:00
2025-04-14 13:26:54 +02:00
- name: Debug registry_login
shell: bash
run: |
source "${{ github.action_path }}/../bashlib.sh"
2025-04-14 13:32:39 +02:00
debug "Registry login is set to -${{ inputs.registry_login }}-"
2025-04-14 13:26:54 +02:00
2025-04-14 13:17:47 +02:00
- name: Log into the registry
2025-04-14 13:32:39 +02:00
if: ${{ inputs.registry_login == 'true' }}
2025-04-14 13:17:47 +02:00
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 }}
2025-04-14 13:02:19 +02:00
2025-04-14 13:17:47 +02:00
- name: Push the images to the serveur
2025-04-14 13:02:19 +02:00
shell: bash
run: |
source "${{ github.action_path }}/../bashlib.sh"
2025-04-14 13:17:47 +02:00
check_command ${{ inputs.push_command }}
2025-04-14 13:02:19 +02:00
2025-04-14 13:17:47 +02:00
IFS=' ' read -r -a tags <<< "${{ inputs.image_tags }}"
debug "Tags parsed: ${tags[*]}"
2025-04-14 13:02:19 +02:00
2025-04-14 13:17:47 +02:00
sep=""
if [[ -n "${tags[0]}" ]] ; then
sep=":"
fi
2025-04-14 13:02:19 +02:00
2025-04-14 13:36:20 +02:00
step "Start pushing" "${{ inputs.image_name }}"
2025-04-14 13:02:19 +02:00
2025-04-14 13:17:47 +02:00
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
2025-04-14 13:02:19 +02:00