Browse Source

Merge pull request #313 from oleorhagen/updatebot

Update the linkbot
2.4.x
oleorhagen 4 years ago
committed by GitHub
parent
commit
4b9dfa8505
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      .github/workflows/automatically-update-test-links.yml
  2. 25
      scripts/linkbot/monitor-rpi.js

11
.github/workflows/automatically-update-test-links.yml

@ -1,7 +1,7 @@
name: automatically-update-test-links name: automatically-update-test-links
on: on:
schedule: schedule:
- cron: "0 13 * * 1" - cron: "0 03 * * 1"
jobs: jobs:
createPullRequest: createPullRequest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -25,7 +25,14 @@ jobs:
title: "Image-Bot: New images available" title: "Image-Bot: New images available"
body: | body: |
New images are available for update New images are available for update
commit-message: Image-Bot - Image updates commit-message: |
Image-Bot - Image updates
Changelog: None
committer: mender-test-bot <mender-test-bot@northern.tech>
author: mender-test-bot <mender-test-bot@northern.tech>
signoff: true
- name: Check outputs - name: Check outputs
run: | run: |

25
scripts/linkbot/monitor-rpi.js

@ -23,6 +23,23 @@ try {
process.exit(1) 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 => { JSDOM.fromURL(url, {}).then(dom => {
var document = dom.window.document; var document = dom.window.document;
var table = document.getElementsByTagName("table"); var table = document.getElementsByTagName("table");
@ -48,7 +65,13 @@ JSDOM.fromURL(url, {}).then(dom => {
}); });
var matchOn = matches[0].input.split("/")[0] var matchOn = matches[0].input.split("/")[0]
if (matchOn !== imageName) { 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/"); 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)
})
} }
}); });

Loading…
Cancel
Save