diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 338b679..3d265f4 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -33,30 +33,37 @@ jobs: - name: Build run: hugo --minify --baseURL /idaas-book - - name: Build image - run: docker build . --file Dockerfile --tag $IMAGE_NAME + - name: Login to dockerhub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + - name: Setup qemu + uses: docker/setup-qemu-action@v1 + with: + platforms: all - - name: Push image - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME + - name: Setup buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - name: Push image + run: | # Strip git ref prefix from version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # Strip "v" prefix from tag name [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "main" ] && VERSION=latest - - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + docker buildx build \ + --tag nxest/idaas-book:$VERSION \ + --tag nxest/idaas-book:lastest \ + --platform linux/amd64,linux/arm64 \ + -f Dockerfile ./ \ + --push