name: docker on: push: branches: - master - dev - travis-multiarch-builds tags: - 'ng-*' jobs: # build and push image to docker hub. buildx: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Cache Docker layers uses: actions/cache@v2 id: cache with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - name: Prepare id: prepare env: DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }} run: | DOCKER_PLATFORMS=linux/amd64 DOCKER_VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then DOCKER_VERSION=${GITHUB_REF#refs/tags/} fi if [[ $GITHUB_REF == refs/heads/* ]]; then DOCKER_VERSION=${GITHUB_REF#refs/heads/} fi DOCKER_TAG="${DOCKER_IMAGE}:${DOCKER_VERSION}" if [[ $DOCKER_VERSION == "master" ]]; then DOCKER_TAG="${DOCKER_IMAGE}:latest" fi echo ::set-output name=version::${DOCKER_VERSION} echo ::set-output name=platforms::${DOCKER_PLATFORMS} echo ::set-output name=tag::${DOCKER_TAG} - name: Docker buildx (build) run: | docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --cache-to "type=local,dest=/tmp/.buildx-cache" \ --output "type=image,push=false" \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VCS_REF=${GITHUB_SHA::8} \ --platform ${{steps.prepare.outputs.platforms}} \ --tag ${{steps.prepare.outputs.tag}} ./ - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Docker Buildx (push) if: false run: | docker buildx build \ --cache-from "type=local,src=/tmp/.buildx-cache" \ --platform ${{steps.prepare.outputs.platforms}} \ --output "type=image,push=true" \ --tag ${{steps.prepare.outputs.tag}} ./ - name: Docker Check Manifest if: false run: | docker run --rm mplatform/mquery ${{steps.prepare.outputs.tag}} - name: Inspect image if: false run: | docker buildx imagetools inspect ${{steps.prepare.outputs.tag}} - name: Clear run: | rm -f ${HOME}/.docker/config.json