Consolidar workflow en un solo step
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 2m15s

Por bug en Gitea que no permite ejecutar múltiples steps,
se consolidó todo el proceso de build y deploy en un único step.
This commit is contained in:
2025-11-21 14:48:59 -06:00
parent 7cabbcef8a
commit 5709b5645d

View File

@@ -5,56 +5,43 @@ on:
branches: [ main, master ] branches: [ main, master ]
jobs: jobs:
#───────────────── build & push ───────────────── build-and-deploy:
build:
runs-on: docker
env:
REG: ${{ vars.REGISTRY_URL }}
APP_NAME: ${{ vars.APP_NAME }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build+push ${{ vars.APP_NAME }}
run: |
cd nuxt4
docker build -t $REG/${{ github.repository_owner }}/$APP_NAME:${{ github.sha }} -t $REG/${{ github.repository_owner }}/$APP_NAME:latest .
docker push $REG/${{ github.repository_owner }}/$APP_NAME:${{ github.sha }}
docker push $REG/${{ github.repository_owner }}/$APP_NAME:latest
#───────────────── deploy ─────────────────
deploy:
needs: build
runs-on: docker runs-on: docker
env: env:
REG: ${{ vars.REGISTRY_URL }} REG: ${{ vars.REGISTRY_URL }}
REPO_OWNER: ${{ github.repository_owner }} REPO_OWNER: ${{ github.repository_owner }}
APP_NAME: ${{ vars.APP_NAME }} APP_NAME: ${{ vars.APP_NAME }}
# Variables de entorno para docker-compose
APP_DOMAIN: ${{ vars.APP_DOMAIN }} APP_DOMAIN: ${{ vars.APP_DOMAIN }}
NUXT_PUBLIC_APP_URL: ${{ vars.NUXT_PUBLIC_APP_URL }} NUXT_PUBLIC_APP_URL: ${{ vars.NUXT_PUBLIC_APP_URL }}
steps: steps:
- uses: actions/checkout@v3 - name: Build, push and deploy
- name: Login to registry
run: docker login ${{ vars.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }}
- name: Info about environment
run: | run: |
echo " Deploying ${{ vars.APP_NAME }}" # Checkout
echo " Domain: ${{ vars.APP_DOMAIN }}" git clone https://gitea.nucleoriofrio.com/${{ github.repository }}.git /tmp/build-${{ github.sha }}
echo " Image: ${{ vars.REGISTRY_URL }}/${{ github.repository_owner }}/${{ vars.APP_NAME }}:latest" cd /tmp/build-${{ github.sha }}
echo " Network: principal" git checkout ${{ github.sha }}
- name: Pull fresh images used in compose # Login to registry
run: docker compose pull docker login $REG -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }}
- name: Clean up stack # Build and push
run: docker compose --project-name $APP_NAME down echo "🔨 Building image..."
cd nuxt4
docker build -t $REG/$REPO_OWNER/$APP_NAME:${{ github.sha }} -t $REG/$REPO_OWNER/$APP_NAME:latest .
echo "📤 Pushing images..."
docker push $REG/$REPO_OWNER/$APP_NAME:${{ github.sha }}
docker push $REG/$REPO_OWNER/$APP_NAME:latest
- name: Update stack # Deploy
run: docker compose --project-name $APP_NAME up -d --remove-orphans --wait cd ..
echo " Deploying $APP_NAME"
echo " Domain: $APP_DOMAIN"
echo " Image: $REG/$REPO_OWNER/$APP_NAME:latest"
docker compose pull
docker compose --project-name $APP_NAME down
docker compose --project-name $APP_NAME up -d --remove-orphans --wait
# Cleanup
cd /
rm -rf /tmp/build-${{ github.sha }}