From 802f8d77c19e484c3830e6c57561d63af6340191 Mon Sep 17 00:00:00 2001
From: Matthew Macdonald-Wallace <matt@doics.co>
Date: Fri, 21 Apr 2023 08:25:55 +0100
Subject: [PATCH] Switch to workflow actions and upload to GHCR

---
 .github/workflows/partial-builder.yml | 95 ++++++++++++++++++++++-----
 1 file changed, 78 insertions(+), 17 deletions(-)

diff --git a/.github/workflows/partial-builder.yml b/.github/workflows/partial-builder.yml
index c0a3b319612..68ab1499f96 100644
--- a/.github/workflows/partial-builder.yml
+++ b/.github/workflows/partial-builder.yml
@@ -39,11 +39,32 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
-      - name: Build Frontend Image
-        run: |
-          docker build --push --no-cache \
-            --tag hkotel/mealie:frontend-${{ inputs.tag }} \
-            --platform linux/amd64,linux/arm64 --file=./docker/frontend.Dockerfile .
+      - name: Log in to the Container registry
+        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Extract metadata (tags, labels) for Docker
+        id: meta
+        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
+        with:
+          images: |
+            hkotel/mealie
+            ghcr.io/${{ github.repository }}
+
+      - name: Build and push Frontend images
+          uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
+          with:
+            file: docker/frontend.Dockerfile
+            context: .
+            push: true
+            tags: frontend-${{ steps.meta.outputs.tags }}
+            labels: ${{ steps.meta.outputs.labels }}
+            platforms:
+              - linux/amd64
+              - linux/arm64
 
   build-backend:
     runs-on: ubuntu-latest
@@ -75,12 +96,32 @@ jobs:
         run: |
           echo "__version__ = \"${{ inputs.tag }}\"" > ./mealie/__init__.py
 
-      - name: Build Backend Image
-        run: |
-          docker build --push --no-cache \
-            --tag hkotel/mealie:api-${{ inputs.tag }}  \
-            --build-arg COMMIT=$(git rev-parse HEAD) \
-            --platform linux/amd64,linux/arm64 --file=./docker/api.Dockerfile .
+      - name: Log in to the Container registry
+        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Extract metadata (tags, labels) for Docker
+        id: meta
+        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
+        with:
+          images: |
+            hkotel/mealie
+            ghcr.io/${{ github.repository }}
+
+      - name: Build and push API images
+          uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
+          with:
+            file: docker/api.Dockerfile
+            context: .
+            push: true
+            tags: api-${{ steps.meta.outputs.tags }}
+            labels: ${{ steps.meta.outputs.labels }}
+            platforms:
+              - linux/amd64
+              - linux/arm64
 
   build-omni:
     runs-on: ubuntu-latest
@@ -112,9 +153,29 @@ jobs:
         run: |
           echo "__version__ = \"${{ inputs.tag }}\"" > ./mealie/__init__.py
 
-      - name: Build Omni-Image
-        run: |
-          docker build --push --no-cache \
-            --tag hkotel/mealie:omni-${{ inputs.tag }}  \
-            --build-arg COMMIT=$(git rev-parse HEAD) \
-            --platform linux/amd64,linux/arm64 --file=./docker/omni.Dockerfile .
+      - name: Log in to the Container registry
+        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Extract metadata (tags, labels) for Docker
+        id: meta
+        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
+        with:
+          images: |
+            hkotel/mealie
+            ghcr.io/${{ github.repository }}
+
+      - name: Build and push API images
+          uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
+          with:
+            file: docker/omni.Dockerfile
+            context: .
+            push: true
+            tags: omni-${{ steps.meta.outputs.tags }}
+            labels: ${{ steps.meta.outputs.labels }}
+            platforms:
+              - linux/amd64
+              - linux/arm64