diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0dea94a2..b4d89052 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -8,10 +8,6 @@ on: pull_request: branches: [ main ] -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - concurrency: # if workflow for PR or push is already running stop it, and start new one group: poc-storage-${{ github.ref }} @@ -20,33 +16,36 @@ concurrency: jobs: storage-push: runs-on: ubuntu-latest - strategy: - matrix: - package: - - server - - spdk steps: - uses: actions/checkout@v3 - uses: docker/setup-qemu-action@v2 - - uses: docker/setup-buildx-action@2dd22fa31c04297d369158eb483250f578504a9f + - uses: docker/setup-buildx-action@v2.4.1 + + - name: Log in to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Log into registry ${{ env.REGISTRY }} + - name: Log in to the GH Container registry if: github.event_name != 'pull_request' - uses: docker/login-action@3da7dc6e2b31f99ef2cb9fb4c50fb0971e0d0139 + uses: docker/login-action@v2.1.0 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata id: meta - uses: docker/metadata-action@766400ca14a75010e7b2e3119aa0d5b46826e8c7 + uses: docker/metadata-action@v4.3.0 with: - images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/opi-storage-${{ matrix.package }} + images: | + ${{ github.repository }} + ghcr.io/${{ github.repository }} - name: Build and push Docker image - if: matrix.package != 'spdk' - uses: docker/build-push-action@b651cf69a6590d1ad24c71a10b292b7130202c9b + uses: docker/build-push-action@v4.0.0 with: context: . platforms: linux/amd64,linux/arm64 @@ -56,11 +55,31 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + spdk-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2.4.1 + + - name: Log in to the GH Container registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4.3.0 + with: + images: ghcr.io/${{ github.repository_owner }}/opi-storage-spdk + - name: Build and push Docker image - if: matrix.package == 'spdk' - uses: docker/build-push-action@b651cf69a6590d1ad24c71a10b292b7130202c9b + uses: docker/build-push-action@v4.0.0 with: - context: ${{ matrix.package }} + context: spdk platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }}