Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dereckson
Last active October 1, 2020 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dereckson/23181a751e014796c52a4011e2a7de22 to your computer and use it in GitHub Desktop.
Save dereckson/23181a751e014796c52a4011e2a7de22 to your computer and use it in GitHub Desktop.
Regenerate DockerHubBuildTriggers.json
triggers = {};
(function () {
var s = document.createElement('script');
s.setAttribute('src', 'https://code.jquery.com/jquery-3.5.1.min.js');
document.body.appendChild(s);
}());
// Pause as we need jQuery object to be available, and so we need to let time to the browser to load the script
jQuery.getJSON("https://hub.docker.com/v2/repositories/nasqueron/?page_size=100", function (response) {
for (result of response["results"]) {
image = result["namespace"] + "%2F" + result["name"];
jQuery.ajax({
url: "https://hub.docker.com/api/build/v1/nasqueron/source/?image=" + image,
context: {image: image.replace("%2F", "/")}
}).done(function (response) {
object = response["objects"][0]
if (object) {
jQuery.ajax({
url: "https://hub.docker.com/api/build/v1/nasqueron/source/" + object["uuid"] + "/trigger/",
context: {image: object["image"]}
}).done(function (response) {
triggers[this["image"]] = response["objects"][0]["url"]
});
} else {
console.warn("No automated build for " + this["image"])
}
})
}
});
// Pause to let some time to the requests to be processed
// We've got a winner :)
console.log(JSON.stringify(triggers))
@dereckson
Copy link
Author

dereckson commented Oct 1, 2020

This procedure allows to fetch the trigger build URL for each automated build repo.

  1. Go to any Docker Hub page
  2. Ensure you're logged in
  3. Run each step in the browser console (steps allow async calls to succeed)

The final object is a JSON document we can publish to /srv/notifications/storage/app/DockerHubBuildTriggers.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment