From 5b1d7d1ea2185256e316f725ce5700980cc2a5a3 Mon Sep 17 00:00:00 2001 From: Alessio Dal Santo Date: Sat, 24 Jan 2026 12:33:04 +0100 Subject: [PATCH] [Fix] Correzione autenticazione Gitea Actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sostituito gitea.actor con username hardcoded 'alessio' - Corretto tutti i riferimenti gitea.ref con github.ref - Gitea Actions usa le stesse variabili di GitHub per compatibilità - Aggiornata documentazione con spiegazione context variables - Fix: username nel docker login ora funzionante --- .gitea/workflows/README.md | 13 +++++++++---- .gitea/workflows/docker-build.yml | 32 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/README.md b/.gitea/workflows/README.md index 606c444..a43295b 100644 --- a/.gitea/workflows/README.md +++ b/.gitea/workflows/README.md @@ -159,14 +159,19 @@ services: ### Principali Differenze 1. **Context Variables**: - - GitHub: `github.*` → Gitea: `gitea.*` - - Esempio: `github.actor` → `gitea.actor` + - Gitea Actions usa le **stesse variabili** di GitHub Actions: `github.*` + - Esempio: `github.ref`, `github.sha`, `github.actor` + - **Nota**: Anche se il servizio è Gitea, le variabili mantengono il prefisso `github` per compatibilità -2. **Registry**: +2. **Username**: + - Nel workflow è hardcoded come `alessio` per semplicità + - Puoi usare `${{ github.actor }}` se preferisci (utente che ha triggerato il workflow) + +3. **Registry**: - GitHub: `ghcr.io` → Gitea: `gitea.home-nas-ds.org` (istanza self-hosted) - Gitea non ha un registry pubblico centralizzato come GitHub -3. **Secret Name**: +4. **Secret Name**: - GitHub: `GITHUB_TOKEN` (automatico) → Gitea: `GITEA_TOKEN` (configurato manualmente) 4. **Attestation**: diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index ffb96fa..1e87b46 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -49,11 +49,11 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | # Tag based on branch - type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' }} - type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/development' }} - type=raw,value=development-latest,enable=${{ gitea.ref == 'refs/heads/development' }} - type=raw,value=dev-latest,enable=${{ gitea.ref == 'refs/heads/dev' }} - type=raw,value=staging-latest,enable=${{ gitea.ref == 'refs/heads/staging' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/development' }} + type=raw,value=development-latest,enable=${{ github.ref == 'refs/heads/development' }} + type=raw,value=dev-latest,enable=${{ github.ref == 'refs/heads/dev' }} + type=raw,value=staging-latest,enable=${{ github.ref == 'refs/heads/staging' }} # Tag with commit sha type=sha,prefix={{branch}}-,format=short # Tag with date @@ -89,7 +89,7 @@ jobs: uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} - username: ${{ gitea.actor }} + username: alessio password: ${{ secrets.GITEA_TOKEN }} - name: Extract metadata for Docker @@ -99,11 +99,11 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | # Tag based on branch with windows suffix - type=raw,value=latest-windows,enable=${{ gitea.ref == 'refs/heads/main' }} - type=raw,value=latest-windows,enable=${{ gitea.ref == 'refs/heads/development' }} - type=raw,value=development-latest-windows,enable=${{ gitea.ref == 'refs/heads/development' }} - type=raw,value=dev-latest-windows,enable=${{ gitea.ref == 'refs/heads/dev' }} - type=raw,value=staging-latest-windows,enable=${{ gitea.ref == 'refs/heads/staging' }} + 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 @@ -149,11 +149,11 @@ jobs: uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} - username: ${{ gitea.actor }} + username: alessio password: ${{ secrets.GITEA_TOKEN }} - name: Create and push manifest for main branch - if: gitea.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' run: | IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]') docker buildx imagetools create -t ${IMAGE_LOWER}:latest \ @@ -161,7 +161,7 @@ jobs: ${IMAGE_LOWER}:latest-windows - name: Create and push manifest for development branch - if: gitea.ref == 'refs/heads/development' + if: github.ref == 'refs/heads/development' run: | IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]') docker buildx imagetools create -t ${IMAGE_LOWER}:latest \ @@ -172,7 +172,7 @@ jobs: ${IMAGE_LOWER}:development-latest-windows - name: Create and push manifest for dev branch - if: gitea.ref == 'refs/heads/dev' + if: github.ref == 'refs/heads/dev' run: | IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]') docker buildx imagetools create -t ${IMAGE_LOWER}:dev-latest \ @@ -180,7 +180,7 @@ jobs: ${IMAGE_LOWER}:dev-latest-windows - name: Create and push manifest for staging branch - if: gitea.ref == 'refs/heads/staging' + if: github.ref == 'refs/heads/staging' run: | IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]') docker buildx imagetools create -t ${IMAGE_LOWER}:staging-latest \