From 03fc1ce56ac11c567744cfb94623d15445636161 Mon Sep 17 00:00:00 2001
From: XargonWan <XargonWan@gmail.com>
Date: Wed, 30 Aug 2023 16:16:20 +0200
Subject: [PATCH] pipelines: moved the branch checking from the pipeline to the
 automation tool

---
 .github/workflows/cooker-selfhosted.yml   | 5 -----
 .github/workflows/main-selfhosted.yml     | 7 +------
 automation_tools/automation_task_list.cfg | 1 +
 3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/cooker-selfhosted.yml b/.github/workflows/cooker-selfhosted.yml
index 61a1cdd9..fc1cd535 100644
--- a/.github/workflows/cooker-selfhosted.yml
+++ b/.github/workflows/cooker-selfhosted.yml
@@ -54,11 +54,6 @@ jobs:
       - name: Run pre-build automation tasks
         run : "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh"
 
-      - name: Set branch in the manifest
-        run: |
-          sed -i "s/THISBRANCH/$(git rev-parse --abbrev-ref HEAD)/g" net.retrodeck.retrodeck.yml
-          echo "Branch name is: $(git rev-parse --abbrev-ref HEAD)"
-
       - name: "Build flatpak: download only"
         id: "flatpak-download"
         run: |
diff --git a/.github/workflows/main-selfhosted.yml b/.github/workflows/main-selfhosted.yml
index 34e5392a..5d9e8d3d 100644
--- a/.github/workflows/main-selfhosted.yml
+++ b/.github/workflows/main-selfhosted.yml
@@ -43,11 +43,6 @@ jobs:
       - name: Run pre-build automation tasks
         run : "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh"
 
-      - name: Set branch in the manifest
-        run: |
-          sed -i "s/branch: THISBRANCH/branch: $(git rev-parse --abbrev-ref HEAD)/g" net.retrodeck.retrodeck.yml
-          echo "Branch name is: $(git rev-parse --abbrev-ref HEAD)"  
-
       - name: Read manifest content
         id: read_manifest
         run: echo "::set-output name=file_content::$(cat net.retrodeck.retrodeck.yml)"
@@ -55,7 +50,7 @@ jobs:
       - name: Check VERSION
         id: check_version_string
         run: |
-          if [[ "${{ steps.read_file.outputs.file_content }}" == *"VERSION=THISBRANCH"* ]]; then
+          if [[ "${{ steps.read_file.outputs.file_content }}" == *"VERSION=THISBRANCH"* ]] || [[ "${{ steps.read_file.outputs.file_content }}" == *"VERSION=main"* ]]; then
             echo "Version string is present, proceeding."
           else
             echo "Error: You forgot to specify the version."
diff --git a/automation_tools/automation_task_list.cfg b/automation_tools/automation_task_list.cfg
index f1624f43..a34f3878 100644
--- a/automation_tools/automation_task_list.cfg
+++ b/automation_tools/automation_task_list.cfg
@@ -9,3 +9,4 @@ hash^MSXBIOSHASHPLACEHOLDER^http://bluemsx.msxblue.com/rel_download/blueMSXv282f
 hash^XEMUHDDHASHPLACEHOLDER^https://github.com/mborgerson/xemu-hdd-image/releases/latest/download/xbox_hdd.qcow2.zip
 latestcommit^UNIVERSALDYNAMICINPUTCOMMITPLACEHOLDER^https://github.com/Venomalia/UniversalDynamicInput^main
 outside_info^VERSIONPLACEHOLDER^${GITHUB_WORKSPACE}/buildid
+outside_info^THISBRANCH^$(git rev-parse --abbrev-ref HEAD)