diff --git a/.gitea/workflows/build-docker.yml b/.gitea/workflows/build-docker.yml index 73dac36..100f176 100644 --- a/.gitea/workflows/build-docker.yml +++ b/.gitea/workflows/build-docker.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - 'v*' # Déclenche aussi le pipeline lors de la création d'un tag jobs: build-and-push: @@ -16,6 +18,16 @@ jobs: - name: Checkout du code uses: actions/checkout@v3 + # NOUVEAU : Génération dynamique des tags (SemVer + Latest) + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: gitea.aethas38.duckdns.org/xavier/multi-ia-codage + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + - name: Connexion au registre Gitea uses: docker/login-action@v2 with: @@ -28,4 +40,5 @@ jobs: with: context: . push: true - tags: gitea.aethas38.duckdns.org/xavier/multi-ia-codage:latest \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b313482..cc9cea3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,8 @@ name: Build and Publish Docker Image on: push: - branches: [ "main" ] # Modifiez si votre branche s'appelle "master" + branches: [ "main" ] + tags: [ 'v*' ] # Déclencheur sur les tags ajouté ici aussi env: REGISTRY: ghcr.io @@ -13,12 +14,22 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - packages: write # Indispensable pour publier le paquet sur le dépôt + packages: write steps: - name: Checkout du code uses: actions/checkout@v4 + # NOUVEAU : Identique à Gitea, gère ghcr.io + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + - name: Connexion au registre GitHub (ghcr.io) uses: docker/login-action@v3 with: @@ -31,4 +42,5 @@ jobs: with: context: . push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file