From 49a001ecbd9727d8e6a4b9d8c97523670b4990fe Mon Sep 17 00:00:00 2001 From: Ole Petter Date: Tue, 2 Mar 2021 11:11:04 +0100 Subject: [PATCH 1/3] Run the cronjob at night, instead of in the middle of the day Changelog: None Signed-off-by: Ole Petter --- .github/workflows/automatically-update-test-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatically-update-test-links.yml b/.github/workflows/automatically-update-test-links.yml index 00685d2..6214add 100644 --- a/.github/workflows/automatically-update-test-links.yml +++ b/.github/workflows/automatically-update-test-links.yml @@ -1,7 +1,7 @@ name: automatically-update-test-links on: schedule: - - cron: "0 13 * * 1" + - cron: "0 03 * * 1" jobs: createPullRequest: runs-on: ubuntu-latest From 8c82096e87e493d8a691a73c8af35681e262c412 Mon Sep 17 00:00:00 2001 From: Ole Petter Date: Tue, 2 Mar 2021 11:12:14 +0100 Subject: [PATCH 2/3] Give the link-bot mender-test-bot as the persona Also signoff all commits Changelog: None Signed-off-by: Ole Petter --- .github/workflows/automatically-update-test-links.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automatically-update-test-links.yml b/.github/workflows/automatically-update-test-links.yml index 6214add..48715af 100644 --- a/.github/workflows/automatically-update-test-links.yml +++ b/.github/workflows/automatically-update-test-links.yml @@ -25,7 +25,14 @@ jobs: title: "Image-Bot: New images available" body: | New images are available for update - commit-message: Image-Bot - Image updates + commit-message: | + Image-Bot - Image updates + + Changelog: None + committer: mender-test-bot + author: mender-test-bot + signoff: true + - name: Check outputs run: | From 4593782706933950484a07213974dfb19c87b011 Mon Sep 17 00:00:00 2001 From: Ole Petter Date: Tue, 2 Mar 2021 12:49:20 +0100 Subject: [PATCH 3/3] Also parse the filename from the new dated sub-folder This is needed, because the dated folders contain images with different names inside of them for some unknown reason. Changelog: None Signed-off-by: Ole Petter --- scripts/linkbot/monitor-rpi.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/linkbot/monitor-rpi.js b/scripts/linkbot/monitor-rpi.js index 058bfb3..3deef38 100644 --- a/scripts/linkbot/monitor-rpi.js +++ b/scripts/linkbot/monitor-rpi.js @@ -23,6 +23,23 @@ try { process.exit(1) } +function getNewRaspbian(url) { + console.log("getNewRaspbian") + console.log(`${url}`) + return JSDOM.fromURL(url, {}).then(dom => { + var document = dom.window.document; + var refs = document.getElementsByTagName("a"); + var test = Array.from(refs) + .filter(ref => ref.textContent.match(("raspbian-.*-lite.*\.zip$"))) + .reduce((acc, element) => { + acc.push(element.textContent.match("raspbian-.*-lite.*\.zip$").input) + return acc + }, [])[0] + return `${target}=\"${url}/${test}\"`; + }); +} + + JSDOM.fromURL(url, {}).then(dom => { var document = dom.window.document; var table = document.getElementsByTagName("table"); @@ -48,7 +65,13 @@ JSDOM.fromURL(url, {}).then(dom => { }); var matchOn = matches[0].input.split("/")[0] if (matchOn !== imageName) { + // We also need to extract the new image name from the index folder, as + // dated folders contain images with different dates in them o_O console.error("We've got a new release! \\o/"); - updateURLLink(`${target}=\"${url}${matches[0].input.split(" ")[0]}-raspbian-buster-lite.zip\"`, target) + var newVar = getNewRaspbian(`${url}${matches[0].input.split(" ")[0].split("/").slice(0, -1)}`) + .then(res => { + console.log(`New release: ${res}`) + updateURLLink(res, target) + }) } });