From 73918eeff37dd454d921ae45abd2dc43cc49da85 Mon Sep 17 00:00:00 2001 From: Nachohernando Date: Mon, 19 Oct 2026 15:09:40 +0000 Subject: [PATCH] Actualizar .gitea/workflows/prueba-imagen.yml --- .gitea/workflows/prueba-imagen.yml | 50 +++++++++++++++++++----------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/.gitea/workflows/prueba-imagen.yml b/.gitea/workflows/prueba-imagen.yml index 66d0aec..ab7dc14 100644 --- a/.gitea/workflows/prueba-imagen.yml +++ b/.gitea/workflows/prueba-imagen.yml @@ -1,13 +1,10 @@ -name: Prueba de construcción de imagen +name: Construir y publicar imagen de prueba on: - push: - paths: - - .gitea/workflows/prueba-imagen.yml workflow_dispatch: jobs: - construir: + publicar: runs-on: gitea-ci timeout-minutes: 15 @@ -20,35 +17,52 @@ jobs: --security-opt systempaths=unconfined steps: - - name: Construir y exportar imagen + - name: Construir y publicar en Gitea shell: sh working-directory: /tmp env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + COMMIT_SHA: ${{ gitea.sha }} BUILDKITD_FLAGS: >- --oci-worker-snapshotter=native --oci-worker-no-process-sandbox run: | set -eu + umask 077 - CONTEXT=$(mktemp -d /tmp/prueba-build.XXXXXX) - trap 'rm -rf "$CONTEXT"' EXIT + : "${REGISTRY_USER:?Falta REGISTRY_USER}" + : "${REGISTRY_TOKEN:?Falta REGISTRY_TOKEN}" + : "${COMMIT_SHA:?Falta COMMIT_SHA}" - cat > "$CONTEXT/Dockerfile" <<'EOF' + WORK=$(mktemp -d /tmp/prueba-registry.XXXXXX) + trap 'rm -rf "$WORK"' EXIT + + mkdir "$WORK/context" "$WORK/auth" + export DOCKER_CONFIG="$WORK/auth" + + AUTH=$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | + base64 | tr -d '\n') + + printf '{"auths":{"git.becodes.com.ar":{"auth":"%s"}}}\n' \ + "$AUTH" > "$DOCKER_CONFIG/config.json" + + unset AUTH REGISTRY_TOKEN REGISTRY_USER + + cat > "$WORK/context/Dockerfile" <<'EOF' FROM alpine:3.23 - RUN printf 'Imagen construida desde Gitea Actions\n' > /prueba.txt \ + RUN printf 'Imagen publicada desde Gitea Actions\n' > /prueba.txt \ && test -s /prueba.txt CMD ["cat", "/prueba.txt"] EOF + IMAGE="git.becodes.com.ar/becodes-team/prueba-infra:ci-${COMMIT_SHA}" + buildctl-daemonless.sh build \ --frontend dockerfile.v0 \ - --local context="$CONTEXT" \ - --local dockerfile="$CONTEXT" \ + --local context="$WORK/context" \ + --local dockerfile="$WORK/context" \ --opt platform=linux/amd64 \ - --output "type=oci,dest=$CONTEXT/imagen.tar" + --output "type=image,name=$IMAGE,push=true" - test -s "$CONTEXT/imagen.tar" - tar -tf "$CONTEXT/imagen.tar" - sha256sum "$CONTEXT/imagen.tar" - - echo "Imagen construida y exportada correctamente" \ No newline at end of file + echo "Imagen publicada: $IMAGE" \ No newline at end of file