From e1b4e0db6615d6380bc7873870d8568466611629 Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Sun, 9 Oct 2022 13:52:30 +0200 Subject: [PATCH] Push each image to an user github registry. It can be used during development for testing. --- .github/workflows/docker-alpine-image.yaml | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-alpine-image.yaml b/.github/workflows/docker-alpine-image.yaml index 9fb9fcd..c6d2cfa 100644 --- a/.github/workflows/docker-alpine-image.yaml +++ b/.github/workflows/docker-alpine-image.yaml @@ -14,12 +14,29 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - + name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Login to DockerHub Container Registry + if: startsWith(github.ref, 'refs/tags/v') + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Docker meta id: meta uses: docker/metadata-action@v4 with: - images: pikvm/ustreamer + images: | + ${{ secrets.DOCKERHUB_USERNAME }}/ustreamer,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + ghcr.io/${{ github.repository }},enable=${{ github.event_name != 'pull_request' }} tags: | type=ref,event=tag type=sha,format=long @@ -51,16 +68,9 @@ jobs: context: . platforms: linux/arm64,linux/amd64,linux/arm/v7 file: pkg/docker/Dockerfile.alpine - - - name: Login to DockerHub - if: startsWith(github.ref, 'refs/tags/v') - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push - if: startsWith(github.ref, 'refs/tags/v') + if: steps.meta.outputs.tags != '' uses: docker/build-push-action@v3 with: context: .