name: Docker Publish # Chaîné sur la CI : l'image :latest n'est publiée que si analyze/test/build # sont verts sur main. L'ancien déclencheur `push: [main]` tournait en # parallèle de la CI et pouvait publier une image cassée. on: workflow_run: workflows: [CI] types: [completed] branches: [main] workflow_dispatch: env: IMAGE_NAME: ghcr.io/r0m1k3/xtremflow jobs: build-and-push: runs-on: ubuntu-latest if: >- github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' permissions: contents: read packages: write steps: - uses: actions/checkout@v4 with: # Sur workflow_run, github.sha pointe sur le commit du workflow # par défaut : construire exactement le commit validé par la CI. ref: ${{ github.event.workflow_run.head_sha || github.sha }} - uses: docker/setup-buildx-action@v3 - name: Log in to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v6 with: context: . file: Dockerfile push: true tags: | ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:${{ github.event.workflow_run.head_sha || github.sha }} cache-from: type=gha cache-to: type=gha,mode=max