From 271fdd466815117bdc5597ec68c6525d5f80164c Mon Sep 17 00:00:00 2001
From: Victor <VictorN076@gmail.com>
Date: Wed, 10 Apr 2024 20:27:28 -0500
Subject: [PATCH] Converting target configuration to JSON file - added json
 file with copy targets - added a bunch of steps to load/parse hte json file -
 altered my copy command to loop through array

---
 .../Configuration/keyboard_nontree.yaml         |  3 ---
 .github/workflows/build_nontree_binaries.yaml   |  1 -
 .github/workflows/qmk_userspace_build.yml       | 17 +++++++++++++++--
 qmk_nontree.json                                |  6 ++++++
 4 files changed, 21 insertions(+), 6 deletions(-)
 delete mode 100644 .github/workflows/Configuration/keyboard_nontree.yaml
 create mode 100644 qmk_nontree.json

diff --git a/.github/workflows/Configuration/keyboard_nontree.yaml b/.github/workflows/Configuration/keyboard_nontree.yaml
deleted file mode 100644
index 7812d86d..00000000
--- a/.github/workflows/Configuration/keyboard_nontree.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-keyboard:
-  - 'barbellboards'
-  - 'planck'
\ No newline at end of file
diff --git a/.github/workflows/build_nontree_binaries.yaml b/.github/workflows/build_nontree_binaries.yaml
index a2eb3ed9..a6dfc5e4 100644
--- a/.github/workflows/build_nontree_binaries.yaml
+++ b/.github/workflows/build_nontree_binaries.yaml
@@ -12,7 +12,6 @@ jobs:
     with:
       qmk_repo: qmk/qmk_firmware
       qmk_ref: master
-      config-file: ./.github/workflows/Configuration/keyboard_nontree.yaml
 
   publish:
     name: 'QMK Userspace Publish'
diff --git a/.github/workflows/qmk_userspace_build.yml b/.github/workflows/qmk_userspace_build.yml
index ee0e1112..8813b5f2 100644
--- a/.github/workflows/qmk_userspace_build.yml
+++ b/.github/workflows/qmk_userspace_build.yml
@@ -61,10 +61,23 @@ jobs:
         run: |
           qmk userspace-doctor
 
+      - name: Install jq
+        run: sudo apt-get install jq
+
+      - name: Import Non Tree Targets JSON file
+        id: read_file
+        run: cat $GITHUB_WORKSPACE/qmk-nontree.json
+
+      - name: Parse Non Tree Targets JSON file
+        id: parse-json
+        run: echo "${{ steps.read_file.outputs.stdout }}" | jq -r '.nontree_targets[]'
+
       - name: Copy Non-Tree Keyboards to QMK Firmware
+        id: loop-targets
         run: |
-          for kb in '${keyboard[@]}'; do
-            cp $GITHUB_WORKSPACE/keyboards/$kb $GITHUB_WORKSPACE/qmk_firmware/keyboards -R
+          for target in ${{ steps.parse-json.outputs.stdout }}; 
+          do
+            cp $GITHUB_WORKSPACE/keyboards/$target $GITHUB_WORKSPACE/qmk_firmware/keyboards -R
           done
 
       - name: Build
diff --git a/qmk_nontree.json b/qmk_nontree.json
new file mode 100644
index 00000000..aa213527
--- /dev/null
+++ b/qmk_nontree.json
@@ -0,0 +1,6 @@
+{
+    "nontree_targets": [
+		"barbellboards",
+		"planck"
+	]
+}
\ No newline at end of file