From 0bcc6939f2e156008b9a8ee21080d8f9b039c1fd Mon Sep 17 00:00:00 2001
From: Xargon Wan <xargonwan@gmail.com>
Date: Sun, 1 May 2022 13:21:33 +0900
Subject: [PATCH] Updated workflow

---
 .github/workflows/cooker.yml | 150 ++++++++++++++++++++++++-----------
 1 file changed, 105 insertions(+), 45 deletions(-)

diff --git a/.github/workflows/cooker.yml b/.github/workflows/cooker.yml
index 93f94383..700164dd 100644
--- a/.github/workflows/cooker.yml
+++ b/.github/workflows/cooker.yml
@@ -37,15 +37,23 @@ jobs:
   #       uses: actions/cache@v2
   #       with:
   #         path:  /home/runner/work/RetroDECK
-  #         key: ${{ runner.os }}-cache
+  #         key: ${{ runner.os }}-cooker-cache
 
   Job2_-_Downloading_Sources:
     runs-on: ubuntu-latest
     #needs: [Job1_-_Prepearing_enviornment]
     steps:
       - uses: actions/checkout@v3
+
+      - name: cache-cooker
+        id: cache-cooker
+        uses: actions/cache@v2
+        with:
+          path:  /home/runner/work/RetroDECK
+          key: ${{ runner.os }}-cooker-cache
+
       - name: Downloading sources
-        if: steps.cache-cooker.outputs.cache-hit != 'true'
+        #if: steps.cache-cooker.outputs.cache-hit != 'true'
         run: |
           git submodule init
           git submodule update
@@ -56,44 +64,35 @@ jobs:
           sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
           sudo flatpak-builder --download-only --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
 
-      - name: cache-cooker
-        id: cache-cooker
-        uses: actions/cache@v2
-        with:
-          path:  /home/runner/work/RetroDECK
-          key: ${{ runner.os }}-cache
+    # - name: Continuing with previous worklow cache
+    #     if: steps.cache-cooker.outputs.cache-hit == 'true'
+    #     run: |
+    #       cd /home/runner/work/RetroDECK/RetroDECK
+    #       git pull
+    #       git submodule init
+    #       git submodule update
+    #       sudo add-apt-repository ppa:alexlarsson/flatpak
+    #       sudo apt-get update
+    #       sudo apt install flatpak flatpak-builder p7zip-full
+    #       sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
+    #       sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
+    #       sudo flatpak-builder --download-only --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
 
   Job3_-_Building_part_1:
     runs-on: ubuntu-latest
     needs: [Job2_-_Downloading_Sources]
     steps:
-      - uses: actions/checkout@v3
-      - name: Bulding part 1 - Until RetroArch Cores
-        if: steps.cache-cooker.outputs.cache-hit != 'true'
-        run: |
-          git submodule init
-          git submodule update
-          sudo add-apt-repository ppa:alexlarsson/flatpak
-          sudo apt-get update
-          sudo apt install flatpak flatpak-builder p7zip-full
-          sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
-          sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
-          sudo flatpak-builder --build-only --stop-at=retroarch-cores --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
+      #- uses: actions/checkout@v3
 
       - name: cache-cooker
         id: cache-cooker
         uses: actions/cache@v2
         with:
           path:  /home/runner/work/RetroDECK
-          key: ${{ runner.os }}-cache
+          key: ${{ runner.os }}-cooker-cache
 
-  Job4_-_Building_part_2:
-    runs-on: ubuntu-latest
-    needs: [Job3_-_Building_part_1]
-    steps:
-      - uses: actions/checkout@v3
-      - name: Bulding part 1 - Until the end
-        if: steps.cache-cooker.outputs.cache-hit != 'true'
+      - name: Initializing enviornment
+        #if: steps.cache-cooker.outputs.cache-hit != 'true'
         run: |
           git submodule init
           git submodule update
@@ -102,54 +101,115 @@ jobs:
           sudo apt install flatpak flatpak-builder p7zip-full
           sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
           sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
-          sudo flatpak-builder --build-only --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
+
+      - name: Bulding part 1 - Until RetroArch Cores
+        if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          cd /home/runner/work/RetroDECK/RetroDECK
+          sudo flatpak-builder --build-only --stop-at=retroarch-cores --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
+
+  Job4_-_Building_part_2:
+    runs-on: ubuntu-latest
+    needs: [Job3_-_Building_part_1]
+    steps:
+      #- uses: actions/checkout@v3
 
       - name: cache-cooker
         id: cache-cooker
         uses: actions/cache@v2
         with:
-          path: /
-          key: ${{ runner.os }}-cache
+          path:  /home/runner/work/RetroDECK
+          key: ${{ runner.os }}-cooker-cache
+
+      - name: Initializing enviornment
+        #if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          git submodule init
+          git submodule update
+          sudo add-apt-repository ppa:alexlarsson/flatpak
+          sudo apt-get update
+          sudo apt install flatpak flatpak-builder p7zip-full
+          sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
+          sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
+
+      - name: Bulding part 1 - Until the end
+        if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          cd /home/runner/work/RetroDECK/RetroDECK
+          sudo flatpak-builder --build-only --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
 
   Job5_-_Finishing_build:
     runs-on: ubuntu-latest
     needs: [Job4_-_Building_part_2]
     steps:
-      - uses: actions/checkout@v3
-      - name: Finishing build
-        if: steps.cache-cooker.outputs.cache-hit != 'true'
-        run: |
-          sudo flatpak-builder --finish-only --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
+      #- uses: actions/checkout@v3
 
       - name: cache-cooker
         id: cache-cooker
         uses: actions/cache@v2
         with:
-          path: /
-          key: ${{ runner.os }}-cache
+          path:  /home/runner/work/RetroDECK
+          key: ${{ runner.os }}-cooker-cache
+
+      - name: Initializing enviornment
+        #if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          git submodule init
+          git submodule update
+          sudo add-apt-repository ppa:alexlarsson/flatpak
+          sudo apt-get update
+          sudo apt install flatpak flatpak-builder p7zip-full
+          sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
+          sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
+
+      - name: Finishing build
+        if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          cd /home/runner/work/RetroDECK/RetroDECK
+          sudo flatpak-builder --finish-only --user --install --force-clean --repo=local retrodeck-flatpak net.retrodeck.retrodeck.yml
 
   Job6_-_Build_bundle:
     runs-on: ubuntu-latest
     needs: [Job5_-_Finishing_build]
     steps:
-      - uses: actions/checkout@v3
-      - name: Build bundle
-        if: steps.cache-cooker.outputs.cache-hit != 'true'
-        run: |
-          sudo flatpak build-bundle local RetroDECK.flatpak net.retrodeck.retrodeck
+      #- uses: actions/checkout@v3
 
       - name: cache-cooker
         id: cache-cooker
         uses: actions/cache@v2
         with:
-          path: /
-          key: ${{ runner.os }}-cache
+          path:  /home/runner/work/RetroDECK
+          key: ${{ runner.os }}-cooker-cache
+
+      - name: Initializing enviornment
+        #if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          git submodule init
+          git submodule update
+          sudo add-apt-repository ppa:alexlarsson/flatpak
+          sudo apt-get update
+          sudo apt install flatpak flatpak-builder p7zip-full
+          sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
+          sudo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13
+
+      - name: Build bundle
+        if: steps.cache-cooker.outputs.cache-hit != 'true'
+        run: |
+          cd /home/runner/work/RetroDECK/RetroDECK
+          sudo flatpak build-bundle local RetroDECK.flatpak net.retrodeck.retrodeck
 
   Job7_-_Publishing_flatpak:
     runs-on: ubuntu-latest
     needs: [Job6_-_Build_bundle]
     steps:
 
+    - name: cache-cooker
+        id: cache-cooker
+        uses: actions/cache@v2
+        with:
+          path:  /home/runner/work/RetroDECK
+          key: ${{ runner.os }}-cooker-cache
+
     - name: Get date for artifacts
       id: date
       run: echo "::set-output name=date::$(date +'%Y%m%d_%H%M')"