π§π§Ή HealthChecks π³ποΈ #729
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: π§π§Ή HealthChecks π³ποΈ | |
on: | |
#push: | |
workflow_dispatch: | |
schedule: | |
- cron: "*/120 * * * *" # Every 120 Mins | |
env: | |
RCLONE_CF_R2_PUB: "${{ secrets.RCLONE_CF_R2_PUB }}" | |
#------------------------------------------------------------------------------------# | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
filter: "blob:none" | |
- 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 | |
#binutils | |
sudo apt install binutils-aarch64-linux-gnu -y | |
#libguestfs-tools | |
sudo apt install libguestfs-tools -y | |
#qemu | |
sudo apt install qemu qemu-user-static qemu-utils -y | |
##qsv: https://github.com/dathere/qsv/tree/master?tab=readme-ov-file#option-2-package-managers--distributions | |
#wget -O - https://dathere.github.io/qsv-deb-releases/qsv-deb.gpg | sudo gpg --dearmor -o /usr/share/keyrings/qsv-deb.gpg | |
#echo "deb [signed-by=/usr/share/keyrings/qsv-deb.gpg] https://dathere.github.io/qsv-deb-releases ./" | sudo tee "/etc/apt/sources.list.d/qsv.list" | |
#sudo apt update -y -qq | |
#sudo apt install qsv -y -qq | |
#temp | |
SYSTMP="$(dirname $(mktemp -u))" && export SYSTMP="${SYSTMP}" | |
echo "SYSTMP=${SYSTMP}" >> "${GITHUB_ENV}" | |
##Setup GHDIRS | |
mkdir -pv "${GITHUB_WORKSPACE}/main/metadata" | |
##Setup rClone | |
mkdir -p "${HOME}/.config/rclone" | |
echo "${{ secrets.RCLONE_CF_R2_PUB }}" > "${HOME}/.config/rclone/rclone.conf" | |
export RCLONE_STATS="120s" ; echo "RCLONE_STATS=${RCLONE_STATS}" >> "${GITHUB_ENV}" | |
##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: Install Addons | |
run: | | |
##presets | |
set +x ; set +e | |
#-------------# | |
#bash <(curl -qfsSL "https://pub.ajam.dev/repos/Azathothas/Arsenal/misc/Linux/install_dev_tools.sh") | |
bash <(curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Arsenal/main/misc/Linux/install_dev_tools.sh") | |
continue-on-error: true | |
- name: Dos2Unix Everything | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
cd "${GITHUB_WORKSPACE}/main" | |
find . -type f ! -path "./.git/*" -exec dos2unix {} \; 2>/dev/null | |
continue-on-error: true | |
- name: ActionLint | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
cd "${GITHUB_WORKSPACE}/main" | |
find ".github/workflows" -type f -name "*ml" -exec actionlint {} \; | |
continue-on-error: true | |
- name: Shellcheck | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
cd "${GITHUB_WORKSPACE}/main" | |
find ".github" -type f -name '*.sh' -exec shellcheck --exclude="SC2261" --severity="error" "{}" \; 2>/dev/null | tee "${GITHUB_WORKSPACE}/main/.github/shellcheck.txt" | |
continue-on-error: true | |
- name: YamlCheck | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
cd "${GITHUB_WORKSPACE}/main" | |
find "packages" -type f -iregex '.*\.\(yml\|yaml\)$' -exec sh -c 'for file; do if ! yq eval "." "$file" > /dev/null 2>&1; then echo "Invalid YAML: $file"; fi; done' sh {} + | tee "${GITHUB_WORKSPACE}/main/.github/yamlcheck.txt" | |
continue-on-error: true | |
- name: Generate Repo Metadata (git-sizer) | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
cd "${GITHUB_WORKSPACE}/main" | |
#Dust sizes | |
echo '```mathematica' > "${GITHUB_WORKSPACE}/main/.github/SIZE.md" | |
dust -b -c -i -r -n 99999999 "${GITHUB_WORKSPACE}/main" | tee -a "${GITHUB_WORKSPACE}/main/.github/SIZE.md" | |
dust -b -c -i -r -n 99999999 "${GITHUB_WORKSPACE}/main" | tee "${GITHUB_WORKSPACE}/main/.github/SIZE.txt" | |
echo '```' >> "${GITHUB_WORKSPACE}/main/.github/SIZE.md" | |
continue-on-error: true | |
- name: Generate Repo Metadata (sbuild-linter) | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
pushd "$(mktemp -d)" >/dev/null 2>&1 | |
curl -qfsSL "https://raw.githubusercontent.com/pkgforge/soarpkgs/refs/heads/main/scripts/gen_meta.sh" -o "./gen_meta.sh" | |
dos2unix --quiet "./gen_meta.sh" ; chmod +x "./gen_meta.sh" | |
bash "./gen_meta.sh" | |
if [[ -s "${SYSTMP}/SBUILD_METADATA.json" ]] && jq --exit-status '.' "${SYSTMP}/SBUILD_METADATA.json" > /dev/null 2>&1; then | |
##Json | |
cp -fv "${SYSTMP}/SBUILD_METADATA.json" "${GITHUB_WORKSPACE}/main/metadata/METADATA.json" | |
b3sum "${GITHUB_WORKSPACE}/main/metadata/METADATA.json" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]' > "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.bsum" | |
7z a -t7z -mx="9" -mmt="$(($(nproc)+1))" -bsp1 -bt "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.xz" "${GITHUB_WORKSPACE}/main/metadata/METADATA.json" 2>/dev/null | |
b3sum "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.xz" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]' > "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.xz.bsum" | |
zstd --ultra -22 --force "${GITHUB_WORKSPACE}/main/metadata/METADATA.json" -o "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.zstd" | |
b3sum "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.zstd" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]' > "${GITHUB_WORKSPACE}/main/metadata/METADATA.json.zstd.bsum" | |
##Sqlite DB | |
cp -fv "${SYSTMP}/SBUILD_METADATA.db" "${GITHUB_WORKSPACE}/main/metadata/METADATA.db" | |
b3sum "${GITHUB_WORKSPACE}/main/metadata/METADATA.db" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]' > "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.bsum" | |
7z a -t7z -mx="9" -mmt="$(($(nproc)+1))" -bsp1 -bt "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.xz" "${GITHUB_WORKSPACE}/main/metadata/METADATA.db" 2>/dev/null | |
b3sum "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.xz" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]' > "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.xz.bsum" | |
zstd --ultra -22 --force "${GITHUB_WORKSPACE}/main/metadata/METADATA.db" -o "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.zstd" | |
b3sum "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.zstd" | grep -oE '^[a-f0-9]{64}' | tr -d '[:space:]' > "${GITHUB_WORKSPACE}/main/metadata/METADATA.db.zstd.bsum" | |
##Failed SBUILDS | |
if [[ -s "${SYSTMP}/INVALID_SBUILDS.txt" || $(stat -c%s "${SYSTMP}/INVALID_SBUILDS.txt") -gt 10 ]]; then | |
#sed 's|.*/packages|https://github.com/pkgforge/soarpkgs/blob/main/packages|' -i "${SYSTMP}/INVALID_SBUILDS.txt" | |
#sed 's|^|- |' -i "${SYSTMP}/INVALID_SBUILDS.txt" | |
#sort -u "${SYSTMP}/INVALID_SBUILDS.txt" -o "${SYSTMP}/INVALID_SBUILDS.txt" | |
export HAS_INVALID="TRUE" | |
echo "HAS_INVALID=${HAS_INVALID}" >> "${GITHUB_ENV}" | |
fi | |
else | |
echo -e "\n[-] FATAL: Metadata Generation Failed" | |
fi | |
popd >/dev/null 2>&1 | |
continue-on-error: true | |
- name: Git Pull & Update Readme | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
cd "${GITHUB_WORKSPACE}/main" && git pull origin main || git pull origin main --ff-only || git merge --no-ff -m "Merge & Sync" | |
##PKG Num | |
#PKG_NUM="$(curl -qfsSL "https://api.gh.pkgforge.dev/repos/pkgforge/soarpkgs/contents/packages" | jq -r '.[] | select(.type == "dir") | .name' | sort -u | wc -l | tr -d '[:space:]')" ; export PKG_NUM | |
PKG_NUM="$(find "${GITHUB_WORKSPACE}/main/packages" -maxdepth 1 -type d -printf '.' | wc -c | tr -d '[:space:]')" ; export PKG_NUM | |
SUBPKG_NUM="$(find "${GITHUB_WORKSPACE}/main/packages" -type f -iregex '.*\.\(yml\|yaml\)$' -printf '.' | wc -c | tr -d '[:space:]')" ; export SUBPKG_NUM | |
sed -E "s#(https://img\.shields\.io/badge/Packages-)[^?]*#\1${PKG_NUM}%20(${SUBPKG_NUM})-blue#" -i "${GITHUB_WORKSPACE}/main/README.md" | |
#sed "s|img.shields.io/badge/Packages-[^/]*-blue|img.shields.io/badge/Packages-${PKG_NUM}-blue|g" -i "${GITHUB_WORKSPACE}/main/README.md" | |
sed -E "s~(https://bin\.pkgforge\.dev/list\.gif)[^\"]*~\1?$(basename "$(mktemp -u)")=$(basename "$(mktemp -u)")~g" -i "${GITHUB_WORKSPACE}/main/README.md" | |
continue-on-error: true | |
#- name: Ensure Healthy Commit Nums (RESET ON >= 100000) | |
# run: | | |
# #Presets | |
# set +x ; set +e | |
# #--------------# | |
# pushd "$(mktemp -d)" >/dev/null 2>&1 && git clone --filter="blob:none" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" | |
# cd "$(find . -maxdepth 1 -type d -exec basename {} \; | grep -Ev '^\.$' | xargs -I {} realpath {})" | |
# CLONED_DIR="$(realpath .)" && export CLONED_DIR="${CLONED_DIR}" | |
# COMMIT_NUMS="$(git rev-list --count HEAD)" && export COMMIT_NUMS="${COMMIT_NUMS}" | |
# popd >/dev/null 2>&1 ; rm -rf "${CLONED_DIR}" 2>/dev/null | |
# cd "${GITHUB_WORKSPACE}/main" | |
# if [ "${COMMIT_NUMS}" -gt 100000 ]; then | |
# echo -e "\n[+] Total number of commits exceeds 100000. (${COMMIT_NUMS})\n" | |
# cd "${GITHUB_WORKSPACE}/main" | |
# git config "user.name" "Azathothas" | |
# git config "user.email" "[email protected]" | |
# git checkout --orphan temp | |
# git add --all --verbose && git commit -m "Purge (Re:Init)" | |
# git branch -D "main" | |
# git branch -m "main" | |
# git push --set-upstream origin main --force | |
# echo "RESET_HISTORY=YES" >> "${GITHUB_ENV}" | |
# else | |
# echo -e "\n[+] Total number of commits looks healthy. (${COMMIT_NUMS})\n" | |
# echo "RESET_HISTORY=NO" >> "${GITHUB_ENV}" | |
# fi | |
# pushd "${GITHUB_WORKSPACE}/main" >/dev/null 2>&1 && git pull origin main && popd >/dev/null 2>&1 | |
# continue-on-error: true | |
- name: Get DateTime & Purge files (=> 95 MB) | |
run: | | |
#Presets | |
set +x ; set +e | |
#--------------# | |
UTC_TIME="$(TZ='UTC' date +'%Y-%m-%d (%I:%M:%S %p)')" | |
echo "UTC_TIME=$UTC_TIME" >> $GITHUB_ENV | |
#Purge | |
find "${GITHUB_WORKSPACE}/main" -path "${GITHUB_WORKSPACE}/main/.git" -prune -o -type f -size +95M -exec rm -rvf "{}" + 2>/dev/null | |
continue-on-error: true | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
repository: ./main | |
commit_user_name: Azathothas | |
commit_user_email: [email protected] | |
#commit_message: "βββββ β" | |
commit_message: "β Updated (Metadata) ποΈ <-- ${{ env.UTC_TIME }} β" | |
#push_options: '--force' | |
continue-on-error: true | |
- name: Create Issue From File | |
if: env.HAS_INVALID == 'TRUE' | |
uses: peter-evans/create-issue-from-file@v5 | |
with: | |
title: SBUILDS (Failed Validation) | |
content-filepath: "/tmp/INVALID_SBUILDS.txt" | |
labels: report, automated issue | |
#------------------------------------------------------------------------------------# | |
- name: rClone BackUp Repo ("https://pub.ajam.dev/repos/${GITHUB_REPOSITORY}") | |
run: | | |
# Presets | |
set +x ; set +e | |
#--------------# | |
#touch "${HOME}/.rclone.conf" | |
echo "${{ secrets.RCLONE_CF_R2_PUB }}" > "${HOME}/.rclone.conf" | |
#chdir to Repo | |
cd "${GITHUB_WORKSPACE}/main" | |
#Git pull | |
git pull origin main --no-edit 2>/dev/null | |
#Del Bloat | |
rm -rf "$(pwd)/.git" | |
#Upload to Pub | |
echo -e "[+] Syncing ${GITHUB_REPOSITORY} to pub.ajam.dev/repos/${GITHUB_REPOSITORY} \n" | |
rclone sync "." "r2:/pub/repos/${GITHUB_REPOSITORY}/" --user-agent="${USER_AGENT}" --buffer-size="100M" --s3-upload-concurrency="500" --s3-chunk-size="100M" --multi-thread-streams="500" --checkers="2000" --transfers="1000" --check-first --checksum --copy-links --fast-list --progress | |
continue-on-error: true | |
#------------------------------------------------------------------------------------# |