diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index 935c55e..ede07cf 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -22,17 +22,33 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: - images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} - - name: Build and push Docker image + images: | + ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} + ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push Docker image to Docker Hub uses: docker/build-push-action@v5 with: context: . @@ -41,3 +57,14 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | GITHUB_REF_NAME=${{ github.ref_name }} + + - name: Build and push Docker image to GitHub Container Registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:${{ github.ref_name }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GITHUB_REF_NAME=${{ github.ref_name }} \ No newline at end of file