diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index b36cff7..5a101cd 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -99,71 +99,44 @@ jobs: packages: write steps: - - name: Setup Node.js for Actions + - name: Checkout repository (manual git) run: | - # Check if node is available - if (!(Get-Command node -ErrorAction SilentlyContinue)) { - Write-Host "Node.js not found, installing..." - choco install nodejs -y --version=20.11.0 - refreshenv - } - node --version - shell: pwsh - continue-on-error: false - - - name: Checkout repository - uses: actions/checkout@v4 + git config --global core.autocrlf false + git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/${{ github.repository }} . + shell: cmd - name: Log in to Gitea Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: alessio - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Extract metadata for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - # Tag based on branch with windows suffix - type=raw,value=latest-windows,enable=${{ github.ref == 'refs/heads/main' }} - type=raw,value=latest-windows,enable=${{ github.ref == 'refs/heads/development' }} - type=raw,value=development-latest-windows,enable=${{ github.ref == 'refs/heads/development' }} - type=raw,value=dev-latest-windows,enable=${{ github.ref == 'refs/heads/dev' }} - type=raw,value=staging-latest-windows,enable=${{ github.ref == 'refs/heads/staging' }} - # Tag with commit sha - type=sha,prefix={{branch}}-windows-,format=short - # Tag with date - type=raw,value={{branch}}-windows-{{date 'YYYYMMDD-HHmmss'}} - flavor: | - latest=false + run: echo ${{ secrets.REGISTRY_TOKEN }} | docker login ${{ env.REGISTRY }} -u alessio --password-stdin + shell: cmd - name: Build and push Windows Docker image run: | - # Convert repository name to lowercase - $imageName = "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}".ToLower() + set BRANCH=${{ github.ref_name }} + set SHA=${{ github.sha }} + set SHORT_SHA=%SHA:~0,7% - # Build with temporary tag - docker build -t "${imageName}:temp-windows" -f Dockerfile.windows . + REM Build image + docker build -t temp-image -f Dockerfile.windows . - # Parse and push all tags - $tags = "${{ steps.meta.outputs.tags }}" -split "`n" - foreach ($tag in $tags) { - $tag = $tag.Trim() - if ($tag) { - # Ensure tag is lowercase - $tag = $tag.ToLower() - Write-Host "Tagging and pushing: $tag" - docker tag "${imageName}:temp-windows" $tag - docker push $tag - } - } + REM Tag and push based on branch + if "%BRANCH%"=="main" ( + docker tag temp-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-windows + ) + 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 + ) + 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 + ) - # Remove temporary tag - docker rmi "${imageName}:temp-windows" - shell: pwsh + REM Clean up + docker rmi temp-image + shell: cmd create-manifest: name: Create Multi-Platform Manifest