Fix Kaniko (+1 squashed commits)

Squashed commits:

[98c2593] Retry Kaniko
This commit is contained in:
2025-06-17 09:58:48 -03:00
parent 8f488405ee
commit 4b95de9ba2

View File

@@ -6,55 +6,54 @@ on:
- main
jobs:
build-and-deploy:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# --- Instalar Docker en el Entorno del Job ---
- name: Install Docker CLI
- name: Create Kaniko config file
run: |
apt-get update
apt-get install -y --no-install-recommends ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce-cli
echo '{"auths":{"${{ secrets.REGISTRY_URL }}":{"username":"${{ secrets.REGISTRY_USER }}","password":"${{ secrets.ACTIONS_PAT }}"}}}' > /kaniko/config.json
# Este comando crea el fichero de credenciales que Kaniko necesita.
# Lo creamos en un directorio que montaremos en el siguiente paso.
- name: Login to Gitea Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.ACTIONS_PAT }}
- name: Build and Push Backend
run: |
docker run --rm \
-v ${{ gitea.workspace }}:/workspace \
-v /kaniko/config.json:/kaniko/.docker/config.json \
gcr.io/kaniko-project/executor:v1.9.0 \
--context=/workspace \
--dockerfile=/workspace/Backend/GestionIntegral.Api/Dockerfile \
--destination=${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-backend:latest \
--destination=${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-backend:${{ gitea.sha_short }} \
--insecure
- name: Build and Push Backend Image
uses: docker/build-push-action@v4
with:
context: .
file: Backend/GestionIntegral.Api/Dockerfile
push: true
tags: ${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-backend:latest,${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-backend:${{ gitea.sha_short }}
- name: Build and Push Frontend Image
uses: docker/build-push-action@v4
with:
context: .
file: Frontend/Dockerfile
push: true
tags: ${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-frontend:latest,${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-frontend:${{ gitea.sha_short }}
- name: Build and Push Frontend
run: |
docker run --rm \
-v ${{ gitea.workspace }}:/workspace \
-v /kaniko/config.json:/kaniko/.docker/config.json \
gcr.io/kaniko-project/executor:v1.9.0 \
--context=/workspace \
--dockerfile=/workspace/Frontend/Dockerfile \
--destination=${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-frontend:latest \
--destination=${{ secrets.REGISTRY_URL }}/${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-frontend:${{ gitea.sha_short }} \
--insecure
deploy:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Deploy to Production
run: |
echo "Deploying to production server..."
# Ya no necesitamos instalar openssh-client, porque la imagen base ya lo tiene.
# Este paso no necesita cambios, pero para mantenerlo simple,
# lo ejecutaremos directamente sin la acción de checkout,
# ya que no necesita los ficheros del repositorio.
apk add --no-cache openssh-client
mkdir -p ~/.ssh
echo "${{ secrets.PROD_SERVER_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa