From eb699625925ea012a8ce5f7253067fbcc05ef2bd Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Mon, 12 Dec 2022 09:15:49 -0500 Subject: [PATCH] build and publish image to Docker Hub (#203) --- .github/workflows/publish-image.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 98e2bab87..f90699cb7 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -21,8 +21,9 @@ env: PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 jobs: - build-and-push-image: - runs-on: ubuntu-latest + build_and_push_image: + name: Build and push Docker image + runs-on: ubuntu-22.04 permissions: contents: read packages: write @@ -50,7 +51,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image + - name: Build and push image to GHCR uses: docker/build-push-action@v3 with: context: . @@ -58,3 +59,23 @@ jobs: platforms: ${{ env.PLATFORMS }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ajustesen/${{ env.IMAGE_NAME }} + + - name: Build and push image to Docker Hub + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}