86 lines
2.5 KiB
YAML
86 lines
2.5 KiB
YAML
|
|
name: 'Install container tools'
|
||
|
|
description: 'Install docker, podman, or skopeo on the runner'
|
||
|
|
author: 'Eric Coissac'
|
||
|
|
|
||
|
|
inputs:
|
||
|
|
tools:
|
||
|
|
description: 'Comma-separated list of tools to install (docker,podman,skopeo)'
|
||
|
|
required: true
|
||
|
|
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: Install container tools
|
||
|
|
shell: bash
|
||
|
|
run: |
|
||
|
|
source "${{ github.action_path }}/../bashlib.sh"
|
||
|
|
|
||
|
|
# Parse la liste des outils
|
||
|
|
IFS=',' read -r -a tools_array <<< "${{ inputs.tools }}"
|
||
|
|
|
||
|
|
step "Installing container tools" "${tools_array[*]}"
|
||
|
|
|
||
|
|
# Pour chaque outil demandé
|
||
|
|
for tool in "${tools_array[@]}"; do
|
||
|
|
# Enlever les espaces
|
||
|
|
tool=$(echo "$tool" | xargs)
|
||
|
|
|
||
|
|
# Vérifier si déjà installé
|
||
|
|
if command -v "$tool" >/dev/null 2>&1; then
|
||
|
|
success "Already installed" "$tool found"
|
||
|
|
continue
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Installer l'outil
|
||
|
|
step "Installing" "$tool"
|
||
|
|
|
||
|
|
case "$tool" in
|
||
|
|
docker)
|
||
|
|
# Docker nécessite une installation spéciale
|
||
|
|
check_command curl
|
||
|
|
|
||
|
|
if curl -fsSL https://get.docker.com -o get-docker.sh && \
|
||
|
|
sh get-docker.sh; then
|
||
|
|
success "Success" "Docker installed"
|
||
|
|
else
|
||
|
|
error "Install failed" "Could not install Docker"
|
||
|
|
fi
|
||
|
|
rm -f get-docker.sh
|
||
|
|
;;
|
||
|
|
|
||
|
|
podman|skopeo)
|
||
|
|
check_command apt-get
|
||
|
|
|
||
|
|
apt-get update -qq
|
||
|
|
|
||
|
|
if apt-get -y install "$tool"; then
|
||
|
|
success "Success" "$tool installed"
|
||
|
|
else
|
||
|
|
error "Install failed" "Could not install $tool"
|
||
|
|
fi
|
||
|
|
;;
|
||
|
|
|
||
|
|
*)
|
||
|
|
error "Unknown tool" "$tool is not supported (docker|podman|skopeo)"
|
||
|
|
;;
|
||
|
|
esac
|
||
|
|
done
|
||
|
|
|
||
|
|
success "Installation complete" "All requested tools installed"
|