Skip to content

Check for new camera-streamer-raspi package #6764

Check for new camera-streamer-raspi package

Check for new camera-streamer-raspi package #6764

name: "Check for new camera-streamer-raspi package"
on:
schedule:
- cron: "23 * * * *"
workflow_dispatch:
jobs:
check-package:
name: "Check packages"
runs-on: ubuntu-latest
steps:
- name: "🔎 Find latest package"
uses: actions/github-script@v6
with:
script: |
let release = null;
console.log("Fetching latest release");
const query = `query {
repository(owner:"OctoPrint", name:"camera-streamer") {
latestRelease {
tagName
releaseAssets(last:10) {
nodes {
name
downloadUrl
}
}
}
}
}`;
const result = await github.graphql(query);
console.log({result});
release = result.repository.latestRelease;
if (!release || !release.tagName || !release.releaseAssets || !release.releaseAssets.nodes) core.setFailed("Could not find OctoPi release");
const tag = release.tagName;
let packageNames = [];
let packageUrls = [];
let found_armhf = false;
let found_arm64 = false;
for (const asset of release.releaseAssets.nodes.reverse()) {
if (asset.name.startsWith("camera-streamer-raspi_") && asset.name.endsWith("_armhf.deb")) {
packageNames.push(asset.name);
packageUrls.push(asset.downloadUrl);
found_armhf = true;
}
if (asset.name.startsWith("camera-streamer-raspi_") && asset.name.endsWith("_arm64.deb")) {
packageNames.push(asset.name);
packageUrls.push(asset.downloadUrl);
found_arm64 = true;
}
if (found_armhf && found_arm64) {
break;
}
}
if (!found_armhf) core.setFailed("Could not find camera-streamer-raspi armhf package");
if (!found_arm64) core.setFailed("Could not find camera-streamer-raspi arm64 package");
console.log("Package names:");
for (const name of packageNames) {
console.log(` ${name}`)
}
console.log("Package URLs:");
for (const url of packageUrls) {
console.log(` ${url}`)
}
core.exportVariable("PACKAGE_NAMES", packageNames.join(" "));
core.exportVariable("PACKAGE_URLS", packageUrls.join(" "));
- name: ⬇ Checkout
uses: actions/checkout@v3
- name: 🤔 Check if package is already in repo
id: check-package-exists
run: |
NAMES=($PACKAGE_NAMES)
URLS=($PACKAGE_URLS)
NEWURLS=()
for i in "${!NAMES[@]}"; do
if [ -f "pool/bullseye/rpi/camera-streamer-raspi/${NAMES[i]}" ]; then
echo "Package ${NAMES[i]} already in repo"
else
echo "Package ${NAMES[i]} not in repo"
NEWURLS+=(${URLS[i]})
fi
done
echo "geturls=${NEWURLS[*]}" >> "$GITHUB_OUTPUT"
- name: Trigger package addition if not yet there
if: steps.check-package-exists.outputs.geturls != ''
uses: benc-uk/workflow-dispatch@v1
with:
workflow: add-package.yml
inputs: '{"urls": "${{ steps.check-package-exists.outputs.geturls }}", "dist": "bullseye", "component": "rpi"}'