⏱️ Schedule Matrix Builds 📈 #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ⏱️ Schedule Matrix Builds 📈 | |
on: | |
workflow_dispatch: | |
jobs: | |
pre-trigger-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
outputs: | |
build_list: ${{ steps.set-inputs.outputs.build_list }} | |
steps: | |
- name: Setup Env | |
run: | | |
##presets | |
set +x ; set +e | |
#-------------# | |
##CoreUtils | |
sudo apt update -y | |
sudo apt install bc coreutils curl dos2unix fdupes jq moreutils wget -y | |
sudo apt-get install apt-transport-https apt-utils ca-certificates coreutils dos2unix gnupg2 jq moreutils p7zip-full rename rsync software-properties-common texinfo tmux util-linux wget -y 2>/dev/null ; sudo apt-get update -y 2>/dev/null | |
#-------------# | |
##Host | |
HOST_TRIPLET="$(uname -m)-$(uname -s)" | |
echo "HOST_TRIPLET=${HOST_TRIPLET}" >> "${GITHUB_ENV}" | |
#-------------# | |
##Repo | |
PKG_REPO="${GITHUB_REPOSITORY}" | |
echo "PKG_REPO=${PKG_REPO#*/}" >> "${GITHUB_ENV}" | |
#-------------# | |
##tmp | |
SYSTMP="$(dirname $(mktemp -u))" && export SYSTMP="${SYSTMP}" | |
echo "SYSTMP=${SYSTMP}" >> "${GITHUB_ENV}" | |
#-------------# | |
mkdir -p "${HOME}/bin" | |
sudo apt update -y | |
sudo apt install dos2unix -y | |
##User-Agent | |
USER_AGENT="$(curl -qfsSL 'https://pub.ajam.dev/repos/Azathothas/Wordlists/Misc/User-Agents/ua_chrome_macos_latest.txt')" && export USER_AGENT="${USER_AGENT}" | |
echo "USER_AGENT=${USER_AGENT}" >> "${GITHUB_ENV}" | |
continue-on-error: true | |
- name: Get & Set Inputs | |
id: set-inputs | |
run: | | |
##presets | |
set +x ; set +e | |
#-------------# | |
##Get Data | |
mkdir -pv "${SYSTMP}/pkgforge" | |
curl -w "(Diff) <== %{url}\n" -qfsSL "https://raw.githubusercontent.com/pkgforge/metadata/refs/heads/main/soarpkgs/data/DIFF_${PKG_REPO}_${HOST_TRIPLET}.json" -o "${SYSTMP}/pkgforge/DIFF.json.tmp" | |
curl -w "(List) <== %{url}\n" "https://raw.githubusercontent.com/pkgforge/${PKG_REPO}/refs/heads/main/SBUILD_LIST.json" -o "${SYSTMP}/pkgforge/SBUILD_LIST.json.tmp" | |
jq -n --slurpfile a "${SYSTMP}/pkgforge/DIFF.json.tmp" --slurpfile b "${SYSTMP}/pkgforge/SBUILD_LIST.json.tmp" \ | |
' | |
[$b[] | .[] as $objB | | |
($a[] | .[] | .build_script | split("/") | .[-3:] | join("/")) as $a_last3 | | |
($objB.build_script | split("/") | .[-3:] | join("/")) as $b_last3 | | |
if $a_last3 == $b_last3 or $objB.rebuild == true then $objB else empty end | |
] | unique_by(.ghcr_pkg) | sort_by(.pkg_family) | |
' | jq . > "${SYSTMP}/pkgforge/SBUILD_LIST.json" | |
##Set Input (100 builds) | |
BUILD_LIST="$(jq -c '[.[] | select(._disabled == false) | {pkg_family, ghcr_url: .ghcr_pkg, sbuild_url: .build_script, rebuild}] | .[:100]' "${SYSTMP}/pkgforge/SBUILD_LIST.json")" | |
echo "build_list=${BUILD_LIST}" >> "${GITHUB_OUTPUT}" | |
##Validate Input | |
if ! echo "${BUILD_LIST}" | jq -e 'type == "array" and length > 0' >/dev/null; then | |
echo -e "\n[-] Input Json is likely Invalid\n" | |
echo "${BUILD_LIST}" | jq . | |
exit 1 | |
else | |
echo -e "\n[+] Generated Input Json\n" | |
ESCAPED_BUILD_LIST="$(echo "${BUILD_LIST}" | jq -c '@json')" | |
echo "build_list=${ESCAPED_BUILD_LIST}" >> "${GITHUB_OUTPUT}" | |
echo "${ESCAPED_BUILD_LIST}" | jq -R 'fromjson | fromjson' | |
fi | |
continue-on-error: false | |
trigger-build: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: read | |
statuses: write | |
strategy: | |
fail-fast: false | |
max-parallel: 20 | |
matrix: | |
package: ${{ fromJSON(fromJSON(needs.pre-trigger-build.outputs.build_list || '{}')) }} | |
steps: | |
- name: Print Matrix Output | |
run: | | |
echo '${{ toJSON(matrix.package) }}' | jq . | |
continue-on-error: true | |
- name: Trigger Matrix Builds | |
if: ${{ toJson(matrix.package) != '{}' }} | |
env: | |
GH_TOKEN: "${{ github.token }}" | |
run: | | |
##presets | |
set +x ; set +e | |
#-------------# | |
gh workflow run "matrix_builds.yaml" \ | |
--repo "${GITHUB_REPOSITORY}" \ | |
--ref "${GITHUB_REF}" \ | |
-f host="ALL" \ | |
-f sbuild-url="${{ matrix.package.sbuild_url }}" \ | |
-f ghcr-url="${{ matrix.package.ghcr_url }}" \ | |
-f pkg-family="${{ matrix.package.pkg_family }}" \ | |
-f debug="false" \ | |
-f logs="true" \ | |
-f rebuild="${{ matrix.package.rebuild }}" | |
continue-on-error: false |