From 502dcfb120dc5ce4d63c1685dfdd8c819019cbe1 Mon Sep 17 00:00:00 2001 From: Kashif Sohail Date: Sun, 12 Dec 2021 19:02:47 +0500 Subject: [PATCH] Update docker-image.yml --- .github/workflows/docker-image.yml | 92 ++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3b145a31..7f83bff3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,24 +1,68 @@ -name: ci-builx - -on: - push: - -jobs: - buildx: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Inspect builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" +name: Docker Build/Publish Image +on: + push: + branches: [ master ] +jobs: + build: + runs-on: ubuntu-18.04 + env: + DOCKER_REGISTRY: kemansel.azurecr.io + DOCKER_IMAGE: kmansel/express-me + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_TARGET_PLATFORM: linux/arm/v7 + steps: + - name: Checkout the code + uses: actions/checkout@v1 + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + version: latest + - name: Prepare + if: success() + id: prepare + run: | + echo ::set-output name=docker_platform::${DOCKER_TARGET_PLATFORM} + echo ::set-output name=docker_image::${DOCKER_REGISTRY}/${DOCKER_IMAGE} + echo ::set-output name=version::${GITHUB_RUN_NUMBER} + - name: Docker Login + if: success() + run: | + echo "${DOCKER_PASSWORD}" | docker login ${DOCKER_REGISTRY} --username "${DOCKER_USERNAME}" --password-stdin + - name: Run Buildx (push image) + if: success() + run: | + docker buildx build \ --platform ${{ steps.prepare.outputs.docker_platform }} \ --tag ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} \ --file ./Dockerfile \ --output type=image,push=true .name: Docker Build/Publish Image +on: + push: + branches: [ master ] +jobs: + build: + runs-on: ubuntu-18.04 + env: + DOCKER_IMAGE: kshfse/dashy + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_TARGET_PLATFORM: linux/arm/v7 + steps: + - name: Checkout the code + uses: actions/checkout@v1 + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + version: latest + - name: Prepare + if: success() + id: prepare + run: | + echo ::set-output name=docker_platform::${DOCKER_TARGET_PLATFORM} + echo ::set-output name=docker_image::${DOCKER_REGISTRY}/${DOCKER_IMAGE} + echo ::set-output name=version::${GITHUB_RUN_NUMBER} + - name: Docker Login + if: success() + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + - name: Run Buildx (push image) + if: success() + run: | + docker buildx build \ --platform ${{ steps.prepare.outputs.docker_platform }} \ --tag ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} \ --file ./docker/Dockerfile-multi-arch \ --output type=image,push=true .