Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch arm64 camera-streamer in GitHub action #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 41 additions & 19 deletions .github/workflows/check-for-new-camera-streamer-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,62 @@ jobs:

const tag = release.tagName;

let packageName = null;
let packageUrl = null;
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")) {
packageName = asset.name;
packageUrl = asset.downloadUrl;
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 (!packageName || !packageUrl) core.setFailed("Could not find camera-streamer-raspi armhf package");

console.log(`Package name: ${packageName}`)
console.log(`Package URL: ${packageUrl}`);
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");

core.exportVariable("PACKAGE_NAME", packageName);
core.exportVariable("PACKAGE_URL", packageUrl);
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: |
if [ -f "pool/bullseye/rpi/camera-streamer-raspi/${{ env.PACKAGE_NAME }}" ]; then
echo "Package already in repo"
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "Package not in repo"
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

NAMES=($PACKAGE_NAMES)
URLS=($PACKAGE_URLS)
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"
echo "geturl=${URLS[i]}" >> "$GITHUB_OUTPUT"
break
Comment on lines +91 to +94
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to lead to issues if we find a new version that has two new packages, and thus two new URLs that need to be fetched? geturl will only ever hold the last URL to fetch, only that will be part of the workflow dispatch below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did this on purpose in order to simplify the logic. Since the workflow runs every hour, the first hour it will do the first URL, and so on until all are done. The rate of new packages showing up is fairly low, and it didn't seem like there would be harm in not updating the repository all at once.

Do you think it would help to include a comment explaining this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually prefer to not have more than one trigger per version, as those will cause two separate PRs. That doesn't sound much, but given my TODO list size that always just seems to grow instead of shrinking, less work items created by automation is ALWAYS the preference.

So let's find a solution instead that will only create one PR per version, regardless of the number of included packages.

fi
done

- name: Trigger package addition if not yet there
if: steps.check-package-exists.outputs.exists != 'true'
if: steps.check-package-exists.outputs.geturl != ''
uses: benc-uk/workflow-dispatch@v1
with:
workflow: add-package.yml
inputs: '{"url": "${{ env.PACKAGE_URL}}", "dist": "bullseye", "component": "rpi"}'
inputs: '{"url": "${{ steps.check-package-exists.outputs.geturl }}", "dist": "bullseye", "component": "rpi"}'