From 1edf0d72ec6d30fa21525b14dfa86726fac51ec4 Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Mon, 21 Jun 2021 17:24:11 +0200 Subject: [PATCH] Update dev-image.yml --- .github/workflows/dev-image.yml | 85 ++++++++++++++++----------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml index 1ea3898..c9ced7c 100644 --- a/.github/workflows/dev-image.yml +++ b/.github/workflows/dev-image.yml @@ -1,56 +1,53 @@ name: Docker Images CI on: push: - branches: [ dev ] + branches: dev + jobs: - docker: + buildx: runs-on: ubuntu-latest steps: - - name: Checkout + - + name: Checkout uses: actions/checkout@v2 - - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} - VERSION=latest - SHORTREF=${GITHUB_SHA::8} - - TAGS="${DOCKER_IMAGE}:dev,${DOCKER_IMAGE}:${SHORTREF}" - - # If the VERSION looks like a version number, assume that - # this is the most recent version of the image and also - # tag it 'latest'. - if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - TAGS="$TAGS,${DOCKER_IMAGE}:latest" - fi - - # Set output parameters. - echo ::set-output name=tags::${TAGS} - echo ::set-output name=docker_image::${DOCKER_IMAGE} - - - name: Set up QEMU - uses: docker/setup-qemu-action@master + - + name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + - + name: Cache Docker layers + uses: actions/cache@v2 + id: cache with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@master - - - name: Login to DockerHub - if: github.event_name != 'pull_request' + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - + name: Docker Buildx (build) + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --platform linux/386,linux/amd64,linux/arm/v7,linux/arm64 \ + --output "type=image,push=false" \ + --tag albertoxamin/bang:dev \ + --file ./Dockerfile-diun ./ + - + name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.prep.outputs.tags }} + - + name: Docker Buildx (push) + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --platform linux/386,linux/amd64,linux/arm/v7,linux/arm64 \ + --output "type=image,push=true" \ + --tag albertoxamin/bang:dev \ + --file ./Dockerfile-diun ./ + - + name: Inspect image + run: | + docker buildx imagetools inspect albertoxamin/bang:dev