From 5e14c1bc223b0ef952c017c8854869191078033d Mon Sep 17 00:00:00 2001 From: Alessio Dal Santo Date: Sat, 24 Jan 2026 13:47:06 +0100 Subject: [PATCH] =?UTF-8?q?[Refactor]=20Ricostruito=20workflow=20Windows?= =?UTF-8?q?=20con=20parit=C3=A0=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stesso flusso e struttura della parte Linux - Download e extract repository migliorato - Debug steps per verificare file e secret - Tagging multipli come Linux (latest, branch-sha, etc.) - Miglior gestione errori e logging - Usa windows-2022 come runner specifico --- .gitea/workflows/docker-build.yml | 89 ++++++++++++++++++------------- 1 file changed, 52 insertions(+), 37 deletions(-) diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index ac4a15b..85062f3 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -93,80 +93,95 @@ jobs: build-windows: name: Build Windows Container - runs-on: windows + runs-on: windows-2022 permissions: contents: read packages: write steps: - - name: Download repository archive + - name: Download and extract repository run: | echo Downloading repository from GitHub... curl -L -o repo.zip https://github.com/${{ github.repository }}/archive/refs/heads/${{ github.ref_name }}.zip echo Extracting archive... tar -xf repo.zip - echo Moving files to current directory... - for /d %%d in (*-${{ github.ref_name }}) do ( - xcopy "%%d\*" . /E /I /Y - rmdir "%%d" /S /Q + echo Moving files... + for /d %%d in (*) do ( + if exist "%%d\.gitignore" ( + xcopy "%%d\*" . /E /H /Y /Q + rmdir "%%d" /S /Q + ) ) del repo.zip - echo Repository downloaded and extracted + echo Repository ready shell: cmd - - name: Debug - Check working directory + - name: Debug - Verify files run: | - echo Current directory: + echo Working directory: cd echo. - echo Files in current directory: - dir - echo. - echo Looking for Dockerfiles: - dir Dockerfile* + echo Dockerfiles found: + dir Dockerfile* /B 2>nul || echo No Dockerfiles found shell: cmd continue-on-error: true + - name: Debug - Verify secret + run: | + if "${{ secrets.REGISTRY_TOKEN }}"=="" ( + echo ERROR: REGISTRY_TOKEN not configured! + exit /b 1 + ) else ( + echo REGISTRY_TOKEN is configured + ) + shell: cmd + - name: Log in to Gitea Container Registry run: echo ${{ secrets.REGISTRY_TOKEN }} | docker login ${{ env.REGISTRY }} -u alessio --password-stdin shell: cmd - name: Build and push Windows Docker image run: | - REM Check if Dockerfile exists - if not exist Dockerfile.windows ( - echo ERROR: Dockerfile.windows not found! - dir - exit /b 1 - ) - + set IMAGE_LOWER=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} set BRANCH=${{ github.ref_name }} set SHA=${{ github.sha }} set SHORT_SHA=%SHA:~0,7% - echo Building Windows image... - REM Build image - docker build -t temp-image -f Dockerfile.windows . - if errorlevel 1 exit /b 1 - - REM Tag and push based on branch + REM Determine tags based on branch + set TAGS= if "%BRANCH%"=="main" ( - docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows + set TAGS=%IMAGE_LOWER%:latest-windows + set TAGS=%TAGS% %IMAGE_LOWER%:main-windows-%SHORT_SHA% ) if "%BRANCH%"=="development" ( - docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows - docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:development-latest-windows - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:development-latest-windows + set TAGS=%IMAGE_LOWER%:latest-windows + set TAGS=%TAGS% %IMAGE_LOWER%:development-latest-windows + set TAGS=%TAGS% %IMAGE_LOWER%:development-windows-%SHORT_SHA% ) if "%BRANCH%"=="staging" ( - docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-latest-windows - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-latest-windows + set TAGS=%IMAGE_LOWER%:staging-latest-windows + set TAGS=%TAGS% %IMAGE_LOWER%:staging-windows-%SHORT_SHA% ) - REM Clean up - docker rmi temp-image + echo Building Windows Docker image... + docker build -t temp-windows -f Dockerfile.windows . + if errorlevel 1 ( + echo Build failed! + exit /b 1 + ) + + echo Tagging and pushing images... + for %%t in (%TAGS%) do ( + echo Tagging: %%t + docker tag temp-windows %%t + echo Pushing: %%t + docker push %%t + ) + + echo Cleaning up temporary image... + docker rmi temp-windows + + echo Windows build completed successfully! shell: cmd create-manifest: