From 8f4109c269fb75bf3a2b0d94f6b0f8d280998b36 Mon Sep 17 00:00:00 2001
From: s3rj1k <evasive.gyron@gmail.com>
Date: Wed, 21 Feb 2024 22:38:58 +0100
Subject: [PATCH 1/2] Add PREBUILD_SCRIPT support.

---
 .github/workflows/ci-deb-packages-v2.yml | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/ci-deb-packages-v2.yml b/.github/workflows/ci-deb-packages-v2.yml
index 47e30b10..1cab8282 100644
--- a/.github/workflows/ci-deb-packages-v2.yml
+++ b/.github/workflows/ci-deb-packages-v2.yml
@@ -38,6 +38,11 @@ on:
         type: string
         default: 'echo "No custom bootstrap script was provided"'
         description: Custom `sh` bootstrap script
+      PREBUILD_SCRIPT:
+        required: false
+        type: string
+        default: 'echo "No custom prebuild script was provided"'
+        description: Custom `sh` prebuild script
       INSTALL_DEPENDENCIES:
         required: false
         type: boolean
@@ -129,6 +134,8 @@ jobs:
         # eval inside runner
         hash=$(echo $GITHUB_SHA | cut -c1-10)
 
+        eval "${{ inputs.PREBUILD_SCRIPT }}"
+
         if [ "${INSTALL_DEPENDENCIES}" = "true" ]; then
           apt-get -q update && \
             mk-build-deps --install --remove debian/control --tool "apt-get -y --no-install-recommends" && \
@@ -172,6 +179,8 @@ jobs:
         # eval inside runner
         hash=$(echo $GITHUB_SHA | cut -c1-10)
 
+        eval "${{ inputs.PREBUILD_SCRIPT }}"
+
         PACKAGE_RELEASE="$GITHUB_RUN_ID.\${hash}" cmake . -DCMAKE_BUILD_TYPE=${{ inputs.CMAKE_BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ inputs.CMAKE_INSTALL_PREFIX }} && make package
 
         EOF
@@ -181,7 +190,7 @@ jobs:
     - name: Set up QEMU
       uses: docker/setup-qemu-action@v3
 
-    - name: build debs
+    - name: Build debs in Docker
       shell: sh
       run: |
         docker run --platform linux/${{ inputs.PLATFORM }} --rm --entrypoint="/usr/local/bin/run.sh" -w /root -v $(pwd):/root -v /tmp/${GITHUB_RUN_ID}/run.sh:/usr/local/bin/run.sh ${{ inputs.BASE_IMAGE }}:${{ inputs.DISTRO_CODENAME }}

From cf10e406460bcc56de66e82079cc716cff54362b Mon Sep 17 00:00:00 2001
From: s3rj1k <evasive.gyron@gmail.com>
Date: Wed, 21 Feb 2024 23:34:40 +0100
Subject: [PATCH 2/2] Add support for passing GENERIC_TOKEN secret into Docker
 DEB builder.

---
 .github/workflows/ci-deb-packages-v2.yml | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/ci-deb-packages-v2.yml b/.github/workflows/ci-deb-packages-v2.yml
index 1cab8282..f81e5a5b 100644
--- a/.github/workflows/ci-deb-packages-v2.yml
+++ b/.github/workflows/ci-deb-packages-v2.yml
@@ -76,6 +76,9 @@ on:
     # outputs:
     #   ARTIFACT_NAME:
     #     value: deb-${{env.IMAGE_TAG}}-${{env.PLATFORM}}-artifact
+    secrets:
+      GENERIC_TOKEN:
+        required: false
 
 jobs:
   build:
@@ -192,8 +195,18 @@ jobs:
 
     - name: Build debs in Docker
       shell: sh
+      env:
+        GENERIC_TOKEN: ${{ secrets.GENERIC_TOKEN }}
       run: |
-        docker run --platform linux/${{ inputs.PLATFORM }} --rm --entrypoint="/usr/local/bin/run.sh" -w /root -v $(pwd):/root -v /tmp/${GITHUB_RUN_ID}/run.sh:/usr/local/bin/run.sh ${{ inputs.BASE_IMAGE }}:${{ inputs.DISTRO_CODENAME }}
+        docker run \
+          --platform linux/${{ inputs.PLATFORM }} \
+          --rm \
+          --entrypoint="/usr/local/bin/run.sh" \
+          -w /root \
+          -v $(pwd):/root \
+          -v /tmp/${GITHUB_RUN_ID}/run.sh:/usr/local/bin/run.sh:ro \
+          -e GENERIC_TOKEN="${GENERIC_TOKEN}" \
+        ${{ inputs.BASE_IMAGE }}:${{ inputs.DISTRO_CODENAME }}
 
     - name: Set custom variables
       shell: sh