From b351e5445d111a121a0996517ab14d88772d5e20 Mon Sep 17 00:00:00 2001 From: Gareth Flowers Date: Wed, 2 Sep 2020 22:51:55 +0100 Subject: [PATCH] chore(ci): use docker buildx action * chore(ci): adds docker buildx action * chore(ci): fixes --- .github/workflows/publish-docker-images.yml | 37 +++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-docker-images.yml b/.github/workflows/publish-docker-images.yml index cfcfe2d..b2bacab 100644 --- a/.github/workflows/publish-docker-images.yml +++ b/.github/workflows/publish-docker-images.yml @@ -11,20 +11,29 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v2 - - name: Push to Docker Hub - uses: docker/build-push-action@v1 + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + - name: Prepare + id: prepare + run: | + DOCKER_IMAGE=garethflowers/ftp-server + DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x + VERSION=latest + + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + fi + + TAGS="--tag ${DOCKER_IMAGE}:${VERSION}" + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest" + fi + + echo ::set-output name=buildx_args::${TAGS} --platform ${DOCKER_PLATFORMS} . + - name: Login to Docker Hub + uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: garethflowers/ftp-server - add_git_labels: true - tag_with_ref: true - - name: Push to GitHub Packages - uses: docker/build-push-action@v1 - with: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - registry: docker.pkg.github.com - repository: ${{ github.repository }}/ftp-server - add_git_labels: true - tag_with_ref: true + - name: Push to Docker Hub + run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}