TEST: actions
Some checks failed
build / build-and-push (push) Failing after 2s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s

This commit is contained in:
2025-12-16 23:54:07 +01:00
parent 26924f459b
commit 0113bbff6b

View File

@@ -8,42 +8,30 @@ on:
jobs:
build-and-push:
runs-on: [k8s, kaniko]
steps:
- name: Instalar y ejecutar Kaniko (todo en uno)
steps:
- name: Instalar y ejecutar Buildah
env:
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: |
# 1. Instalar Kaniko
KANIKO_VERSION="v1.19.0"
echo "📦 Instalando Kaniko ${KANIKO_VERSION}..."
curl -sfL https://github.com/GoogleContainerTools/kaniko/releases/download/${KANIKO_VERSION}/kaniko-executor \
-o /tmp/kaniko-executor
chmod +x /tmp/kaniko-executor
# 2. Configurar credenciales
echo "🔐 Configurando credenciales..."
mkdir -p /kaniko/.docker
AUTH_TOKEN=$(echo -n "$NEXUS_USER:$NEXUS_PASSWORD" | base64)
cat > /kaniko/.docker/config.json <<EOF
{
"auths": {
"nexus.server.duckdns.org": {
"auth": "${AUTH_TOKEN}"
}
}
}
EOF
# 3. Construir y subir imagen
echo "🚀 Ejecutando Kaniko..."
/tmp/kaniko-executor \
--context=. \
--dockerfile=./Dockerfile \
--destination=nexus.rancherk3.duckdns.org/tfm/microserviciospytho:latest \
--destination=nexus.rancherk3.duckdns.org/tfm/microserviciospytho:${{ gitea.sha }} \
--cache=true \
--cache-ttl=72h \
--verbosity=info
echo "📦 Instalando Buildah"
apt-get install -y buildah
echo "🔐 Configurando credenciales para el registro"
echo "[[registry]]" > /etc/containers/registries.conf
echo "prefix = \"nexus.rancherk3.duckdns.org\"" >> /etc/containers/registries.conf
echo "location = \"nexus.rancherk3.duckdns.org\"" >> /etc/containers/registries.conf
echo "insecure = true" >> /etc/containers/registries.conf
#echo "Iniciando sesión en el registro"
#echo $NEXUS_PASSWORD | buildah login -u $NEXUS_USER --password-stdin nexus.rancherk3.duckdns.org
echo "🚀 Construyendo imagen con Buildah"
buildah bud -f Dockerfile -t nexus.rancherk3.duckdns.org/tfm/microserviciospython:latest .
buildah tag nexus.rancherk3.duckdns.org/tfm/microserviciospython:latest nexus.rancherk3.duckdns.org/tfm/microserviciospython:${GITHUB_SHA}
echo "🚀 Subiendo imágenes"
buildah push nexus.rancherk3.duckdns.org/tfm/microserviciospython:latest
buildah push nexus.rancherk3.duckdns.org/tfm/microserviciospython:${GITHUB_SHA}
echo "✅ Imagen construida y subida exitosamente"