diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index d213d1d..a09693a 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -11,19 +11,15 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 20 # Aumentamos a 20 min para evitar que se corte el clone steps: - name: Checkout del código uses: actions/checkout@v3 with: - fetch-depth: 1 # IMPORTANTE: Solo descarga el último commit, no todo el historial + fetch-depth: 0 # Clonar todo para evitar errores de historial - # 1. NUEVO: Generamos la versión semántica dinámica - name: Definir Versión Semántica id: vars - run: | - # Formato v1.0.X (X = número de ejecución del pipeline) - echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_OUTPUT + run: echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_OUTPUT - name: Login en Gitea Registry uses: docker/login-action@v2 @@ -32,7 +28,6 @@ jobs: username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - # 2. ACTUALIZADO: Usamos la nueva variable para los tags de Docker - name: Construir y Subir Imagen uses: docker/build-push-action@v4 with: @@ -42,25 +37,19 @@ jobs: gitea.cruzcloud.net/devops/ecommerce-frontend:${{ steps.vars.outputs.VERSION }} gitea.cruzcloud.net/devops/ecommerce-frontend:latest - # 3. ACTUALIZADO: Inyectamos la versión limpia en el manifiesto YAML - name: Actualizar Manifiesto GitOps (CD) run: | - git config user.name "Cristian Felipe" - git config user.email "cristiancruz0529@gmail.com" + # 1. Configuración de identidad + git config --global user.name "Gitea Actions" + git config --global user.email "actions@gitea.cruzcloud.net" - # 1. Forzamos a Git a ignorar la historia local y sincronizarse 100% con el servidor - git fetch origin main - git reset --hard origin/main + # 2. Sincronización agresiva: asegurar que estamos en la rama correcta + git checkout main - # 2. Aplicamos el cambio de versión + # 3. Aplicar el cambio sed -i -E "s|(image: gitea.cruzcloud.net/devops/ecommerce-frontend:).*|\1${{ steps.vars.outputs.VERSION }}|g" workloads/ecommerce/frontend.yaml - # 3. Solo hacemos commit si realmente hubo un cambio + # 4. Commit y Push forzado git add workloads/ecommerce/frontend.yaml - if git diff --cached --quiet; then - echo "No hay cambios en el manifiesto." - else - git commit -m "chore: release ${{ steps.vars.outputs.VERSION }} [skip ci]" - # 4. Forzamos el push usando --force para limpiar cualquier discrepancia - git push origin HEAD:main --force - fi \ No newline at end of file + git commit -m "chore: release ${{ steps.vars.outputs.VERSION }} [skip ci]" || exit 0 + git push origin main --force \ No newline at end of file