diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bc78ff48a..e4cf72a7d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,7 +55,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - + + - name: Install buildx + env: + DOCKER_CLI_EXPERIMENTAL: enabled + run: | + BUILDX_VERSION="0.4.2" + QEMU_TAG="latest" + mkdir -p ~/.docker/cli-plugins/ + curl -L https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64 \ + -o ~/.docker/cli-plugins/docker-buildx + chmod +x ~/.docker/cli-plugins/docker-buildx + docker pull -q multiarch/qemu-user-static:latest + docker run --rm --privileged multiarch/qemu-user-static:${QEMU_TAG} --reset -p yes --credential yes + docker buildx create --name builder-${GITHUB_SHA::8} --driver docker-container --use + docker buildx inspect --bootstrap + docker info + docker buildx inspect + + - name: Available platforms + run: docker buildx inspect | grep Platforms + - name: Prepare platform list id: platform run: | @@ -144,15 +164,38 @@ jobs: DOCKER_CLI_EXPERIMENTAL: enabled run: | if [ ! -z "${{ steps.prepare_push.outputs.buildx_args }}" ]; then - BUILDX_ARGS=="${{ steps.prepare_push.outputs.buildx_args }}" + BUILDX_ARGS="${{ steps.prepare_push.outputs.buildx_args }}" elif [ ! -z "${{ steps.prepare_release.outputs.buildx_args }}" ]; then - BUILDX_ARGS=="${{ steps.prepare_release.outputs.buildx_args }}" + BUILDX_ARGS="${{ steps.prepare_release.outputs.buildx_args }}" fi - echo "docker buildx build --cache-to \"type=local,dest=/tmp/.buildx-cache\" \ - --output \"type=image,push=false\" \ - $BUILDX_ARGS" + + docker buildx build --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --output "type=image,push=false" \ + $BUILDX_ARGS - - name: Continue + - name: Docker Hub login + if: success() + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push images from cache + if: success() + env: + DOCKER_CLI_EXPERIMENTAL: enabled + run: | + if [ ! -z "${{ steps.prepare_push.outputs.buildx_args }}" ]; then + BUILDX_ARGS="${{ steps.prepare_push.outputs.buildx_args }}" + elif [ ! -z "${{ steps.prepare_release.outputs.buildx_args }}" ]; then + BUILDX_ARGS="${{ steps.prepare_release.outputs.buildx_args }}" + fi + + docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" \ + --output "type=image,push=false" \ + $BUILDX_ARGS + + - name: Inspect images run: | echo "::warning push - ${{ steps.prepare_push.outputs.buildx_args }}" echo "::warning release - ${{ steps.prepare_release.outputs.buildx_args }}"