message: tidy up the docker build
diff: @@ -14,51 +14,37 @@ jobs:
  runs-on: ubuntu-latest
  steps:
  - uses: actions/checkout@v2
  - - uses: crazy-max/ghaction-docker-buildx@v3
  -
  - - name: Prepare
  - id: prepare
  - run: |
  - DOCKER_IMAGE=robertslando/zwave2mqtt
  - DOCKER_PLATFORMS=linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386
  -
  - echo ::set-output name=docker_image::${DOCKER_IMAGE}
  - echo ::set-output name=docker_platforms::${DOCKER_PLATFORMS} \
  -
  - - name: Just build on PR
  - if: ${{ github.event_name == 'pull_request' }}
  - run: |
  - docker buildx build \
  - -f docker/Dockerfile \
  - --platform ${{ steps.prepare.outputs.docker_platforms }} \
  - -t ${{ steps.prepare.outputs.docker_image }}:dev \
  - .
  + - uses: docker/setup-buildx-action@v1
  + - uses: docker/setup-qemu-action@v1
  - name: Login to dockerhub
  if: ${{ github.event_name != 'pull_request' }}
  - run: |
  - docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
  - env:
  - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
  - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
  + uses: docker/login-action@v1
  + with:
  + username: ${{ secrets.DOCKER_USERNAME }}
  + password: ${{ secrets.DOCKER_PASSWORD }}
  - - name: Dev
  - if: ${{ github.ref == 'refs/heads/master'}}
  - run: |
  - docker buildx build \
  - -f docker/Dockerfile \
  - --platform ${{ steps.prepare.outputs.docker_platforms }} \
  - -t ${{ steps.prepare.outputs.docker_image }}:dev \
  - --push \
  - .
  -
  - - name: Latest & tag
  - if: ${{ github.event_name == 'release' }}
  + - name: Prepare
  run: |
  - docker buildx build \
  - -f docker/Dockerfile \
  - --platform ${{ steps.prepare.outputs.docker_platforms }} \
  - -t ${{ steps.prepare.outputs.docker_image }}:$(echo ${GITHUB_REF} | sed "s/refs\/tags\/v//") \
  - -t ${{ steps.prepare.outputs.docker_image }}:latest \
  - --push \
  - .
  + DOCKER_REPO=robertslando/zwave2mqtt
  + if [ "$GITHUB_REF" == "refs/heads/master" ]; then
  + TAGS="${DOCKER_REPO}:dev\n"
  + fi
  + if [ "$GITHUB_EVENT_NAME" == "release" ]; then
  + TAGS="${TAGS}${DOCKER_REPO}:latest\n"
  + TAGS="${TAGS}${DOCKER_REPO}:$(echo ${GITHUB_REF} | sed "s/refs\/tags\/v//")\n"
  + fi
  +
  + TAGS="${TAGS}${DOCKER_REPO}:sha-${GITHUB_SHA}"
  +
  + echo TAGS="${TAGS}" >> $GITHUB_ENV
  + echo DOCKER_REPO="${DOCKER_REPO}" >> $GITHUB_ENV
  +
  + - name: build+push
  + uses: docker/build-push-action@v2
  + with:
  + cache-from: type=registry,ref=${{ env.DOCKER_REPO }}:sha-${{ env.GITHUB_SHA }}
  + platforms: linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386
  + file: docker/Dockerfile
  + push: ${{ github.event_name != 'pull_request' }}
  + tags: ${{ env.TAGS }}
  