[Refactor] Ricostruito workflow Windows con parità Linux
- 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
This commit is contained in:
@@ -93,80 +93,95 @@ jobs:
|
|||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
name: Build Windows Container
|
name: Build Windows Container
|
||||||
runs-on: windows
|
runs-on: windows-2022
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download repository archive
|
- name: Download and extract repository
|
||||||
run: |
|
run: |
|
||||||
echo Downloading repository from GitHub...
|
echo Downloading repository from GitHub...
|
||||||
curl -L -o repo.zip https://github.com/${{ github.repository }}/archive/refs/heads/${{ github.ref_name }}.zip
|
curl -L -o repo.zip https://github.com/${{ github.repository }}/archive/refs/heads/${{ github.ref_name }}.zip
|
||||||
echo Extracting archive...
|
echo Extracting archive...
|
||||||
tar -xf repo.zip
|
tar -xf repo.zip
|
||||||
echo Moving files to current directory...
|
echo Moving files...
|
||||||
for /d %%d in (*-${{ github.ref_name }}) do (
|
for /d %%d in (*) do (
|
||||||
xcopy "%%d\*" . /E /I /Y
|
if exist "%%d\.gitignore" (
|
||||||
rmdir "%%d" /S /Q
|
xcopy "%%d\*" . /E /H /Y /Q
|
||||||
|
rmdir "%%d" /S /Q
|
||||||
|
)
|
||||||
)
|
)
|
||||||
del repo.zip
|
del repo.zip
|
||||||
echo Repository downloaded and extracted
|
echo Repository ready
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- name: Debug - Check working directory
|
- name: Debug - Verify files
|
||||||
run: |
|
run: |
|
||||||
echo Current directory:
|
echo Working directory:
|
||||||
cd
|
cd
|
||||||
echo.
|
echo.
|
||||||
echo Files in current directory:
|
echo Dockerfiles found:
|
||||||
dir
|
dir Dockerfile* /B 2>nul || echo No Dockerfiles found
|
||||||
echo.
|
|
||||||
echo Looking for Dockerfiles:
|
|
||||||
dir Dockerfile*
|
|
||||||
shell: cmd
|
shell: cmd
|
||||||
continue-on-error: true
|
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
|
- name: Log in to Gitea Container Registry
|
||||||
run: echo ${{ secrets.REGISTRY_TOKEN }} | docker login ${{ env.REGISTRY }} -u alessio --password-stdin
|
run: echo ${{ secrets.REGISTRY_TOKEN }} | docker login ${{ env.REGISTRY }} -u alessio --password-stdin
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- name: Build and push Windows Docker image
|
- name: Build and push Windows Docker image
|
||||||
run: |
|
run: |
|
||||||
REM Check if Dockerfile exists
|
set IMAGE_LOWER=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
if not exist Dockerfile.windows (
|
|
||||||
echo ERROR: Dockerfile.windows not found!
|
|
||||||
dir
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
set BRANCH=${{ github.ref_name }}
|
set BRANCH=${{ github.ref_name }}
|
||||||
set SHA=${{ github.sha }}
|
set SHA=${{ github.sha }}
|
||||||
set SHORT_SHA=%SHA:~0,7%
|
set SHORT_SHA=%SHA:~0,7%
|
||||||
|
|
||||||
echo Building Windows image...
|
REM Determine tags based on branch
|
||||||
REM Build image
|
set TAGS=
|
||||||
docker build -t temp-image -f Dockerfile.windows .
|
|
||||||
if errorlevel 1 exit /b 1
|
|
||||||
|
|
||||||
REM Tag and push based on branch
|
|
||||||
if "%BRANCH%"=="main" (
|
if "%BRANCH%"=="main" (
|
||||||
docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows
|
set TAGS=%IMAGE_LOWER%:latest-windows
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows
|
set TAGS=%TAGS% %IMAGE_LOWER%:main-windows-%SHORT_SHA%
|
||||||
)
|
)
|
||||||
if "%BRANCH%"=="development" (
|
if "%BRANCH%"=="development" (
|
||||||
docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows
|
set TAGS=%IMAGE_LOWER%:latest-windows
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows
|
set TAGS=%TAGS% %IMAGE_LOWER%:development-latest-windows
|
||||||
docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:development-latest-windows
|
set TAGS=%TAGS% %IMAGE_LOWER%:development-windows-%SHORT_SHA%
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:development-latest-windows
|
|
||||||
)
|
)
|
||||||
if "%BRANCH%"=="staging" (
|
if "%BRANCH%"=="staging" (
|
||||||
docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-latest-windows
|
set TAGS=%IMAGE_LOWER%:staging-latest-windows
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-latest-windows
|
set TAGS=%TAGS% %IMAGE_LOWER%:staging-windows-%SHORT_SHA%
|
||||||
)
|
)
|
||||||
|
|
||||||
REM Clean up
|
echo Building Windows Docker image...
|
||||||
docker rmi temp-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
|
shell: cmd
|
||||||
|
|
||||||
create-manifest:
|
create-manifest:
|
||||||
|
|||||||
Reference in New Issue
Block a user