Cambios 1026
Some checks failed
Build and Deploy / build-and-push (push) Successful in 10s
Build and Deploy / deploy (push) Failing after 9s

This commit is contained in:
2025-06-17 10:26:19 -03:00
parent 226b1667c2
commit b78475e8ed

View File

@@ -8,41 +8,20 @@ on:
jobs: jobs:
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Create Kaniko config file - name: Create Kaniko config file
run: | run: echo '{"auths":{"${{ secrets.REGISTRY_URL }}":{"username":"${{ secrets.REGISTRY_USER }}","password":"${{ secrets.ACTIONS_PAT }}"}}}' > ${{ gitea.workspace }}/config.json
# Escribimos el config en el workspace, que sabemos que existe.
echo '{"auths":{"${{ secrets.REGISTRY_URL }}":{"username":"${{ secrets.REGISTRY_USER }}","password":"${{ secrets.ACTIONS_PAT }}"}}}' > ${{ gitea.workspace }}/config.json
- name: Build and Push Backend - name: Build and Push Backend
run: | run: |
docker run --rm \ docker run --rm -v ${{ gitea.workspace }}:/workspace -v ${{ gitea.workspace }}/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
-v ${{ gitea.workspace }}:/workspace \
# Montamos el config desde el workspace a la ruta que Kaniko espera.
-v ${{ gitea.workspace }}/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 Frontend - name: Build and Push Frontend
run: | run: |
docker run --rm \ docker run --rm -v ${{ gitea.workspace }}:/workspace -v ${{ gitea.workspace }}/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
-v ${{ gitea.workspace }}:/workspace \
# Hacemos lo mismo para el frontend.
-v ${{ gitea.workspace }}/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: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -51,34 +30,22 @@ jobs:
steps: steps:
- name: Install Docker CLI - name: Install Docker CLI
run: | run: |
apt-get update apt-get update && apt-get install -y docker-ce-cli
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
- name: Deploy to Production - name: Deploy Application Stack
run: | run: |
echo "Deploying to production from within the Docker network..." echo "Deploying application stack..."
docker run --rm \ docker run --rm \
--network gitea-stack_gitea_net \ --network gitea-stack_gitea_net \
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
-v /opt/gestion-integral:/opt/gestion-integral \ -v /opt/gestion-integral:/app \
-w /opt/gestion-integral \ -w /app \
--env DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD_SECRET }}' \ --env DB_SA_PASSWORD=${{ secrets.DB_SA_PASSWORD_SECRET }} \
--env JWT_KEY='${{ secrets.JWT_KEY_SECRET }}' \ --env JWT_KEY=${{ secrets.JWT_KEY_SECRET }} \
--env REGISTRY_URL='${{ secrets.REGISTRY_URL }}' \
--env REGISTRY_USER='${{ secrets.REGISTRY_USER }}' \
--env ACTIONS_PAT='${{ secrets.ACTIONS_PAT }}' \
docker/compose:latest \ docker/compose:latest \
sh -c "docker login \$REGISTRY_URL -u \$REGISTRY_USER -p \$ACTIONS_PAT && docker compose pull && docker compose up -d" sh -c "docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.ACTIONS_PAT }} && docker compose pull && docker compose up -d"
echo "Cleaning up dangling images on host..." - name: Cleanup dangling images
run: |
echo "Cleaning up old images..."
docker image prune -af docker image prune -af