forked from linuxserver/wheelie
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (69 loc) · 4.52 KB
/
Copy pathwheelie_scheduler.yml
File metadata and controls
72 lines (69 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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)
VERSION=3.14.4
DISTRO=ubuntu-resolute
docker run -d --rm --name python-${VERSION} ghcr.io/trueforge-org/python:${VERSION}
CPYTHON=$(docker exec python-${VERSION} bash -c "printf \"\$(python3 -V)\" | awk '{print \$2}' | awk 'BEGIN{FS=OFS=\".\"} NF--' | sed 's|\.||g' | sed 's|^|cp|g'")
for PACKAGE in ${ALLPACKAGES}; do
if echo "${PACKAGES}" | grep -q "${PACKAGE}"; then
break
fi
for ARCH in x86_64 aarch64; do
if ! grep -iq "${PACKAGE}-${VERSION}-${CPYTHON}.*${ARCH}.whl" "docs/${DISTRO}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*manylinux.*${ARCH}.whl" "docs/${DISTRO}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*musllinux.*${ARCH}.whl" "docs/${DISTRO}/index.html" && ! grep -iq "${PACKAGE}-${VERSION}.*abi3.*${ARCH}.whl" "docs/${DISTRO}/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
if echo "${PACKAGES}" | grep -q "${PACKAGE}"; then
break
fi
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