Skip to content

Wheelie Scheduler #34527

Wheelie Scheduler

Wheelie Scheduler #34527

name: Wheelie Scheduler
on:
schedule:
- cron: '00 * * * *'
workflow_dispatch:
jobs:
wheelie-scheduler:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Check for updates and trigger
run: |
ALLPACKAGES=$(cat packages.txt)
DISTROS=$(cat distros.txt)
for DISTRO in ${DISTROS}; do
IMAGE=$(echo ${DISTRO} | awk -F'-' '{print $1}')
TAG=$(echo ${DISTRO} | awk -F'-' '{print $2}')
docker run -d --rm --name ${IMAGE}-${TAG} ghcr.io/linuxserver/baseimage-${IMAGE}:${TAG}
docker exec ${IMAGE}-${TAG} bash -c "\
if [ -f /usr/bin/apt ]; then \
apt-get update && apt-get install -y python3-venv; \
else \
apk add --no-cache python3; \
fi && \
mkdir -p /lsiopy && \
python3 -m venv /lsiopy && \
/lsiopy/bin/pip install -U pip"
done
for PACKAGE in ${ALLPACKAGES}; do
for DISTRO in ${DISTROS}; do
if echo "${PACKAGES}" | grep -q "${PACKAGE}"; then
break
fi
IMAGE=$(echo ${DISTRO} | awk -F'-' '{print $1}')
TAG=$(echo ${DISTRO} | awk -F'-' '{print $2}')
if [ "${IMAGE}" = "alpine" ]; then
OS="${DISTRO}"
else
OS="${IMAGE}"
fi
VERSION=$(docker exec ${IMAGE}-${TAG} bash -c "/lsiopy/bin/pip install ${PACKAGE}==0 2>&1 | sed -rn 's|^.*versions:(.*)\).*$|\1|p' | sed 's%[0-9.]*\(a\|b\|rc\|dev\)[0-9]*%%g' | sed 's%,%%g' | awk '{print \$(NF)}'")
CPYTHON=$(docker exec ${IMAGE}-${TAG} bash -c "printf \"\$(python3 -V)\" | awk '{print \$2}' | awk 'BEGIN{FS=OFS=\".\"} NF--' | sed 's|\.||g' | sed 's|^|cp|g'")
if [ "${DISTRO}" = "alpine-3.23" ]; then
for ARCH in x86_64 aarch64 riscv64; do
if ! grep -iq "${PACKAGE}-${VERSION}-${CPYTHON}.*${ARCH}.whl" "docs/${OS}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*manylinux.*${ARCH}.whl" "docs/${OS}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*musllinux.*${ARCH}.whl" "docs/${OS}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*abi3.*${ARCH}.whl" "docs/${OS}/index.html"; then
echo "**** Adding ${PACKAGE}-${VERSION} to build list ****"
PACKAGES="${PACKAGE} ${PACKAGES}"
break
else
echo "**** ${PACKAGE}-${VERSION}-${CPYTHON}-${ARCH} wheel already built for ${DISTRO}, skipping ****"
fi
done
else
for ARCH in x86_64 aarch64; do
if ! grep -iq "${PACKAGE}-${VERSION}-${CPYTHON}.*${ARCH}.whl" "docs/${OS}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*manylinux.*${ARCH}.whl" "docs/${OS}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*musllinux.*${ARCH}.whl" "docs/${OS}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*abi3.*${ARCH}.whl" "docs/${OS}/index.html"; then
echo "**** Adding ${PACKAGE}-${VERSION} to build list ****"
PACKAGES="${PACKAGE} ${PACKAGES}"
break
else
echo "**** ${PACKAGE}-${VERSION}-${CPYTHON}-${ARCH} wheel already built for ${DISTRO}, skipping ****"
fi
done
fi
if echo "${PACKAGES}" | grep -q "${PACKAGE}"; then
break
fi
done
done
if [ -n "$PACKAGES" ]; then
if [ $(curl -s https://ci.linuxserver.io/job/Tools/job/wheelie/lastBuild/api/json | jq -r '.building') == "false" ] && [ $(curl -s https://ci.linuxserver.io/job/Tools/job/wheelieHA/lastBuild/api/json | jq -r '.building') == "false" ] && [ $(curl -s https://ci.linuxserver.io/job/Tools/job/wheelieSCI/lastBuild/api/json | jq -r '.building') == "false" ]; then
echo "**** Triggering wheelie for packages: ${PACKAGES}****"
response=$(curl -iX POST --data-urlencode "PACKAGES=${PACKAGES}" \
https://ci.linuxserver.io/job/Tools/job/wheelie/buildWithParameters \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
echo "**** Jenkins job queue url: ${response%$'\r'} ****"
echo "**** Sleeping 10 seconds until job starts ****"
sleep 10
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
buildurl="${buildurl%$'\r'}"
echo "**** Jenkins job build url: ${buildurl} ****"
echo "**** Attempting to change the Jenkins job description ****"
curl -iX POST \
"${buildurl}submitDescription" \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--data-urlencode "Submit=Submit"
echo "**** Notifying discord ****"
TRIGGER_REASON="Triggering wheelie for packages: ${PACKAGES}"
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
"description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
else
echo "**** New packages are available but there is already an active Wheelie build, skipping ****"
echo "**** Notifying Discord ****"
FAILURE_REASON="New packages are available but there is already an active Wheelie build, skipping."
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
"description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}],
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
fi
else
echo "**** No new updates to any of the packages, skipping trigger ****"
fi