diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 277adeb..ed46a83 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,9 +42,6 @@ jobs: - name: Checkout the source code uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build -t ghcr.io/${{ github.repository }}/${{ matrix.image }}:latest ${{ matrix.image }}/ - - name: Authenticate with GitHub Container Registry uses: docker/login-action@v3 with: @@ -53,6 +50,16 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} if: github.event_name == 'push' && github.ref == 'refs/heads/master' - - name: Upload the Docker image to GitHub Container Registry - run: docker push ghcr.io/${{ github.repository }}/${{ matrix.image }}:latest - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}/${{ matrix.image }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.image }}/ + push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}