From d9ec212fc79b8a4585dbf6103c023e81ea2f78eb Mon Sep 17 00:00:00 2001
From: XargonWan <XargonWan@gmail.com>
Date: Mon, 19 Sep 2022 14:13:07 +0200
Subject: [PATCH] Added workflow to push cooke to flathub

---
 .github/workflows/flathub_push_cooker.yml | 75 +++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 .github/workflows/flathub_push_cooker.yml

diff --git a/.github/workflows/flathub_push_cooker.yml b/.github/workflows/flathub_push_cooker.yml
new file mode 100644
index 00000000..76e1a77f
--- /dev/null
+++ b/.github/workflows/flathub_push_cooker.yml
@@ -0,0 +1,75 @@
+name: push-cooker-flathub
+
+#on:
+#  push:
+#    branches:
+#     - cooker*
+#  pull_request: 
+#    branches:
+#     - cooker*
+
+#  workflow_dispatch:
+
+
+jobs:
+
+  Pushing_cooker_into_flathub:
+    runs-on: self-hosted
+    steps:
+
+      - name: Pushing
+        run:
+          |
+          # EDITABLES:
+          rd_branch="cooker"
+          gits_folder="gits" # without last /
+
+          # NON-EDITABLES
+          branch="$rd_branch-"$(date +%d%m%y.%H%M)
+
+          mkdir -p $gits_folder
+          cd $gits_folder
+          rm -rf flathub
+          git clone --recursive https://github.com/flathub/net.retrodeck.retrodeck.git flathub
+          git clone --recursive https://github.com/XargonWan/RetroDECK RetroDECK
+          cd $gits_folder/RetroDECK
+          git checkout $rd_branch
+          git submodule init
+          git submodule update
+          # NOTE: the only linked submodules are: rd-submodules/retroarch
+          # these must be included in the exclusion list as they must be redownloaded
+          #sync -rav --progress --exclude={'res/screenshots/','shared-modules/','rd-submodules/retroarch','.git/','docs','retrodeck-flatpak/','retrodeck-flatpak-cooker/','.flatpak-builder/'} ~/RetroDECK/ ~/flathub/
+
+          cd $gits_folder/flathub
+          git checkout -b $branch
+          git rm -rf *
+          git clean -fxd # restroing git index
+
+          # Copying only a few files as the others are cloned by git in retrodeck.sh
+          cd $gits_folder/RetroDECK
+          cp -rf \
+          'rd-submodules' \
+          'flathub.json' \
+          'LICENSE' \
+          'net.retrodeck.retrodeck.appdata.xml' \
+          'net.retrodeck.retrodeck.desktop' \
+          'net.retrodeck.retrodeck.yml' \
+          'README.md' \
+          $gits_folder/flathub/
+          cd $gits_folder/flathub
+
+          rm -rf .git/modules/*
+          # Adding the real submodules, please update this every time a submodule is added
+          git rm -rf shared-modules
+          git submodule add https://github.com/flathub/shared-modules.git shared-modules
+
+          git rm -rf rd-submodules/retroarch
+          git submodule add https://github.com/flathub/org.libretro.RetroArch.git rd-submodules/retroarch
+
+          # unbinds all submodules
+          git submodule deinit -f .
+          # checkout again
+          git submodule update --init --recursive
+          git add *
+          git commit -m "Updated flathub/net.retrodeck.retrodeck from RetroDECK/$rd_branch"
+          git push origin $branch
\ No newline at end of file