From 50e9403857f0e35c1c21634ccb3117656e5d0ff8 Mon Sep 17 00:00:00 2001 From: Travis Shivers Date: Tue, 8 Sep 2020 14:26:21 -0500 Subject: [PATCH] build(release): switch to official docker build action --- .github/workflows/release.yml | 157 +++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 70 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce4545cd..90d748b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,25 +77,32 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Prepare - id: prepare + id: prep run: | DOCKER_IMAGE=${{ github.event.repository.full_name }} - DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x - TAGS="--tag ${DOCKER_IMAGE}:latest --tag ${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }} --tag ${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}" + TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }},${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}" + + echo ::set-output name=tags::${TAGS} echo ::set-output name=docker_image::${DOCKER_IMAGE} - echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ - --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ - --build-arg REVISION=${GITHUB_SHA} \ - --build-arg VERSION=${{ needs.release.outputs.release-version }} \ - --cache-from "type=local,src=/tmp/.buildx-cache" \ - --cache-to "type=local,dest=/tmp/.buildx-cache" \ - ${TAGS} --file ./Dockerfile ./ + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + + - + name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Set up Docker Buildx - uses: crazy-max/ghaction-docker-buildx@v3 + id: buildx + uses: docker/setup-buildx-action@master + with: + version: latest + - name: Cache Docker layers uses: actions/cache@v2 @@ -109,34 +116,36 @@ jobs: ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} ${{ runner.os }}-buildx- + - - name: Docker Buildx (build) - run: | - docker buildx build \ - --output "type=image,push=false" \ - ${{ steps.prepare.outputs.buildx_args }} + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - - name: Docker Login - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x + tags: ${{ steps.prep.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + build-args: | + VERSION=${{ needs.release.outputs.release-version }} + BUILD_DATE=${{ steps.prep.outputs.build_date }} + REVISION=${{ github.sha }} + - - name: Docker Buildx (push) + name: Check manifest run: | - docker buildx build \ - --output "type=image,push=true" \ - ${{ steps.prepare.outputs.buildx_args }} - - - name: Docker Check Manifest - run: | - docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ needs.release.outputs.release-version }} - - - name: Clear - if: always() - run: | - rm -f ${HOME}/.docker/config.json + docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ needs.release.outputs.release-version }} + buildx-web: needs: release @@ -146,25 +155,32 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Prepare - id: prepare + id: prep run: | DOCKER_IMAGE=ttshivers/syncloungeweb - DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x - TAGS="--tag ${DOCKER_IMAGE}:latest --tag ${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }} --tag ${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}" + TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }},${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}" + + echo ::set-output name=tags::${TAGS} echo ::set-output name=docker_image::${DOCKER_IMAGE} - echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ - --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ - --build-arg REVISION=${GITHUB_SHA} \ - --build-arg VERSION=${{ needs.release.outputs.release-version }} \ - --cache-from "type=local,src=/tmp/.buildx-cache" \ - --cache-to "type=local,dest=/tmp/.buildx-cache" \ - ${TAGS} --file ./Dockerfile.web ./ + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + + - + name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Set up Docker Buildx - uses: crazy-max/ghaction-docker-buildx@v3 + id: buildx + uses: docker/setup-buildx-action@master + with: + version: latest + - name: Cache Docker layers uses: actions/cache@v2 @@ -178,31 +194,32 @@ jobs: ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }} ${{ runner.os }}-buildx-${{ hashFiles('**/package-lock.json') }} ${{ runner.os }}-buildx- + - - name: Docker Buildx (build) - run: | - docker buildx build \ - --output "type=image,push=false" \ - ${{ steps.prepare.outputs.buildx_args }} + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - - name: Docker Login - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile.web + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x + tags: ${{ steps.prep.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + build-args: | + VERSION=${{ needs.release.outputs.release-version }} + BUILD_DATE=${{ steps.prep.outputs.build_date }} + REVISION=${{ github.sha }} + - - name: Docker Buildx (push) + name: Check manifest run: | - docker buildx build \ - --output "type=image,push=true" \ - ${{ steps.prepare.outputs.buildx_args }} - - - name: Docker Check Manifest - run: | - docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ needs.release.outputs.release-version }} - - - name: Clear - if: always() - run: | - rm -f ${HOME}/.docker/config.json + docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ needs.release.outputs.release-version }}